How to convert negative numbers and fractions to binary?

How to convert negative numbers and fractions to binary ?

@Arnav7 hey,
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.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.