# Negative decimal to other base conversion

I'm trying to learn on how to convert a negative decimal number (with fraction) to binary, octal and hexadecimal.

So, base 10: -89.3125

Here is what I did to convert this to binary:

-89= 1011001 (positive) // 0100110 (invert) // +1 (add one) =0100111

I then represent the number in paper as (1)0100111

For the fraction part:

1-0,3125=0,6875=1,1011

So final result: (1)0100111,1011

Converting this result to Octal: 647,54

And to Hexadecimal: A7,B

I'd like to know if my logic of conversion is correct, for the Octal/Hexadecimal conversion, I simply divided the binary number in groups of 3 and 4 respectively - from right to left before the ',' and left to right after the ','.

I tried finding an online calculator for all of this, but to no success... so I'm kinda shooting in the dark here.

## 1 Answer

The $-$ sign is not something special to base $10$. In general if $83.5_{10} = 1010011.1_2$ then $-83.5_{10} = -1010011.1_2$. What you are doing here is an extension of two's complement. Two's complement is a method to represent both positive and negative numbers in binary without using a $-$ and is used in computing. Also, it only works for integers. This is how fractions are represented.

• I see. I read about converting fraction from here: uk-calling.com/other/binary/binary_conversion.htm , so I'm guessing this technique also follows the two's complement rule? – Joao Ferreira Sep 1 '12 at 10:38
• I'm not sure what kind of representation that text is talking about. The words "sign bit" should hint that some use with computers is intended. The method of converting positive fractions is correct. – Karolis Juodelė Sep 1 '12 at 11:31
• There's more than one way of representing fractions - just a pair of integers is sometimes a good one. – Ben Millwood Sep 1 '12 at 14:19