negative decimal binary number (twos complement )

Thread Starter

antiantianti

Joined Aug 4, 2016
45
Hi
I have a problem i want to convert 2.5 to binary and after that to subtract 2.5 from another number . I did however convert 2.5 to binary(10.1). I know how to find the twos complement but not from a decimal number . Can you help ?
Thanks
 

WBahn

Joined Mar 31, 2012
32,707
Normally non-integer values are represented using a floating point representation, with the main one being one of the IEEE-754 variants.

If you want to use fixed point, then you need to decide what the width of your representation is (how many bits total) and where the radix point is located.
 

Papabravo

Joined Feb 24, 2006
22,058
With 3 bits and the binary point to the right of the second digit you can represent the following numbers

00.0 = 0.0
00.1 = 0.5
01.0 = 1.0
01.1 = 1.5
10.0 = -2.0
10.1 = -1.5
11.0 = -1.0
11.1 = -0.5

So you cant really get where you want to go with three bits and a signed representation.
 
Top