I would like to ask about how to represent negative fraction decimal numbers to signed binary. for example what is -0.5 in binary.
-
It's -0.1, since - 2^-1 = - 0.5 – Ctx Feb 24 '17 at 13:26
4 Answers
First you can consider the negative number as positive. After finding the decimal and fraction parts seperately you can convert it to negative by making all 1s to 0s and 0s to 1s. Finally you need to add 1.
For example to convert -5.75 to binary first we need to decide the position of the point and the length of the binary number. Let's define the lenght of the number as 8 bits, 4 bits for decimal and 4 bits for fraction parts.
First find the binary representation of (positive) 5.75:
5=0101
0.75=.1100 then
5.75=0101.1100 in 8 bits
To convert negative, procedure is standard, invert all bits and add 1 to the least significand digit.
number: 0101.1100
inversion: 1010.0011
addition of 1: 1010.0011 + 0.0001=1010.0100
Let's check if our repsresentation is correct or not:
1010.0100 => -8 + 2 + 0.25 = -5.75
That's all.

- 321
- 3
- 6
I hope you find this helpful.
- The below deals with converting decimal to binary. If you want to make this negative, then just add a minus sign after you are done. (e.g. convert 25.5 to binary 11001.1, so -25.5 is -11001.1)
If you want to deal with signed binary (something different) then go to the source I linked and read more about that. The source has an online calculator for you to use.
Source: http://www.realbinaryconverter.com/index.php
Converting Decimal Fractions to Binary Fractions
Taking a number like 436.656625 and trying to convert to binary is an easy process. Let's not concern ourselves here with converting the whole integer part (436) because that has been covered at the linked site. All we have to do now is convert the binary fraction part (.656625) and then combine it with the binary whole integer part.
Multiply 0.656625 by 2: 0.656625*2=1.31325
Keep note of that 1 from the whole part
Remove the 1. Now we have 0.31325
Repeat step 2: multiply by 2: 0.31325*2=0.6265
Keep note of that 0 from the whole part
Multiply by 2: 0.6265*2=1.253
Keep note of that 1 from the whole part
Remove the 1. Now we have 0.253
Multiply by 2: 0.253*2=0.506
Keep note of that 0 from the whole part
Multiply by 2: 0.506*2=1.012
Keep note of that 1 from the whole part
Remove the 1. Now we have 0.012
Repeat this process of: multiplying by two and noting the resulting whole integer part. If the whole integer part is 1, note the one then remove the one and continue this process. ...
In the end, our binary fraction comes out as .10101000000110... (and it goes on). I will now demonstrate with a simpler result. Converting 0.8125 to binary.
0.8125*2=1.625, we get 1
0.625*2=1.25, we get 1
0.25*2=0.5, we get 0
0.5*2=1.0, we get 1
Nothing left!
Now take the numbers we got and place them after the decimal point in the order we got them. 0.8125 = 0.1101 in binary.
Now to answer your specific question
Multiply 0.5 by 2: 0.5*2=1.0
Keep note of that 1 from the whole part
Remove the 1. Now we have 0
Nothing left! Now we take the numbers we got and place them after the decimal point in the order we got them. 0.5 = 0.1 in binary.
So -0.5 = -0.1 in binary. You can check this at the source provided.

- 325
- 3
- 8
Just like decimal, digits to the left of the decimal point are rising powers of the base, and digits to the right are reducing powers.
So 124.71
is:
10^2 10^1 10^0 10^-1 10^-2
100 + 20 + 4 + 7/10 + 1/100
With binary, it's the same, except the rising powers are 1, 2, 4, 8, ...
rather than 1, 10, 100, 1000, ...
.
And the reducing powers aren't 1/10, 1/100, 1/1000, ...
but 1/2, 1/4, 1/8, ...
.
So -0.5
is an easy one since it consists of only the 1/2
place, in binary:
-0.1: - means it will be negative.
0 x 2^0(1) = 0
1 x 2^-1(1/2) = 0.5
----
-0.5
More complex numbers are built by summing the individual places. For example, decimal 65.625
is:
1 x 2^6 = 64
0 x 2^5
0 x 2^4
0 x 2^3
0 x 2^2
0 x 2^1
1 x 2^0(1) = 1
.
1 x 2^-1 = 0.5
0 x 2^-2
1 x 2^-3 = 0.125
^ ------
| 65.625
|
+-> 1000001.101

- 854,327
- 234
- 1,573
- 1,953
-
thanks for your answer but I was wondering how to represent -.5 completely in binary but in the question your number has a negative sign. so how we were taught in school is that if the number is negative you make the integer negative. but the question is how can we make the integer negative if the integer is 0 – Abdelrahman M. Mohey El-din Feb 24 '17 at 13:57
-
@AbdelrahmanM.MoheyEl-din, that depends on how you encode the sign. Typically (such as with IEEE754 encoding), you dedicate one of the bits to represent sign. If it's zero, it's considered positive, whereas one represents negative. This leads to the existence of *two* zeros, one positive and one negative, which some mathematical people insist is proof positive that computer scientists shouldn't be trusted with math :-) More detail can be found at http://stackoverflow.com/questions/3448777/how-to-represent-0-1-in-floating-point-arithmetic-and-decimal/3448855#3448855 – paxdiablo Feb 24 '17 at 14:06
It is a relatively simple operation to convert a negative decimal(base-10) number to binary(base-2).
I'll take -10 for example. The first thing you should do is represent positive 10 in binary : 01010. The next step is to flip all the bits, which means change the zero's to one's and vice versa; 10101. The final step is to add 1 to 10101, which results into 10110.

- 43
- 7