Decimal to Binary 32 bit signed conversion

  • Thread starter Thread starter Willjeezy
  • Start date Start date
  • Tags Tags
    Binary Bit
Click For Summary

Discussion Overview

The discussion revolves around converting the decimal number -89 into a 32-bit binary representation, specifically using two's complement for negative numbers. Participants explore different methods of conversion, including floating-point representation, and clarify the steps involved in the process.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant attempts to convert -89 by calculating the closest power of 2, suggesting that the exponent is 7 and adding it to the bias of 127 to arrive at 134.
  • Another participant questions the approach, indicating that the conversion should focus on integer representation rather than floating-point format, suggesting it complicates the problem unnecessarily.
  • There is a correction regarding the exponent, with a suggestion that the correct power of 2 closest to 89 should be 26, not 27, leading to confusion about the calculations presented.
  • One participant humorously notes the mention of 2^64, which is incorrect in the context of the conversion, and acknowledges the mistake in the exponent calculation.
  • A hint is provided to convert 89 to hexadecimal as an alternative approach.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the correct method for conversion, with multiple competing views on whether to use integer or floating-point representation and how to calculate the exponent accurately.

Contextual Notes

There are unresolved mathematical steps regarding the conversion process, particularly in distinguishing between integer and floating-point representations. The discussion reflects varying interpretations of the problem and its requirements.

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.
 

Similar threads

  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 5 ·
Replies
5
Views
6K
Replies
4
Views
2K
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 13 ·
Replies
13
Views
4K
Replies
7
Views
14K