Decimal to Binary 32 bit signed conversion

  • Thread starter Thread starter Willjeezy
  • Start date Start date
  • Tags Tags
    Binary Bit
AI Thread Summary
The discussion focuses on converting -89 into a 32-bit signed binary representation using two's complement. The original poster mistakenly attempted to use floating-point representation instead of the correct integer format, leading to confusion regarding the exponent and bias. They calculated the exponent as 7, which was incorrect; the correct exponent should be 6, corresponding to the closest power of 2 less than or equal to 89. This error resulted in discrepancies when comparing their answer to conversion sites, which provided a different exponent. Ultimately, the conversation highlights the importance of using the correct method for integer conversion rather than floating-point representation.
Willjeezy
Messages
29
Reaction score
0

Homework Statement


Convert -89 to 32 bit representation (2-complement for negative numbers)

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

Homework Equations





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?
 
Physics news on Phys.org
Willjeezy said:

Homework Statement


Convert -89 to 32 bit representation (2-complement for negative numbers)

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

Homework Equations





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?

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.
 
Willjeezy said:
what am I doing wrong?
As Mark44 noted, you're solving the wrong problem. :wink:

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.
 
2^64? I think you blew my mind

89 = 1.390625 * 64
 
Hint: convert 89 to Hex.
 
vela said:
As Mark44 noted, you're solving the wrong problem. :wink:

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.
vela was thinking 6 but mistakenly wrote 64.
SteamKing said:
2^64? I think you blew my mind

89 = 1.390625 * 64
 
SteamKing said:
2^64? I think you blew my mind

89 = 1.390625 * 64
Oops. Thanks for catching that.
 
Back
Top