# Decimal to Binary 32 bit signed conversion

1. Mar 7, 2013

### Willjeezy

1. The problem statement, all variables and given/known data
Convert -89 to 32 bit representation (2-complement for negative numbers)

my answer does not agree with calculated answers from multiple conversion sites.

2. Relevant equations

3. The attempt at a solution

to get the exponent i figured out the closest 2 exponent to 89, which is 7.

then I added the exponent to the bias, 127 + 7 = 134

therefore 134 to binary would be: (I added underscores to separate the sign/exponent and mantissa

1__________1 0 0 0 0 1 1 0___________0 1 1 0 0 1
sign___________exponent______________ mantissa

the only problem is when i check my answer on multiple sites, the answer is

1 __________1 0 0 0 0 1 0 1 ___________0 1 1 0 0 1

_____________________^---exponent they have adds up to 133 ?

what am I doing wrong?

2. Mar 7, 2013

### Staff: Mentor

Why are you converting to floating point form? The number you need to convert is an integer. You're making this much harder than it actually needs to be.

3. Mar 8, 2013

### vela

Staff Emeritus
As Mark44 noted, you're solving the wrong problem.

But to answer the question you asked anyway, you don't want 27. You want 26, the power of 2 that's closest to 89 but less than or equal to 89. This gives you
$$89 = 1.390625 \times 2^{64}$$ which has a mantissa with the integer part equal to 1, which is what you want if you're going to convert to floating-point format.

4. Mar 8, 2013

### SteamKing

Staff Emeritus
2^64? I think you blew my mind

89 = 1.390625 * 64

5. Mar 8, 2013

### SteamKing

Staff Emeritus
Hint: convert 89 to Hex.

6. Mar 8, 2013

### Staff: Mentor

vela was thinking 6 but mistakenly wrote 64.

7. Mar 8, 2013

### vela

Staff Emeritus
Oops. Thanks for catching that.