Decimal to Binary 32 bit signed conversion

  • Thread starter Willjeezy
  • Start date
  • Tags
    Binary Bit
In summary: Fixed it. :)In summary, the conversation discusses converting -89 to 32 bit representation, and the individual's attempt to use floating-point form instead of the correct method for integers. The correct exponent for this conversion is 26, which gives a mantissa with an integer part of 1.
  • #1
Willjeezy
29
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
  • #2
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.
 
  • #3
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.
 
  • #4
2^64? I think you blew my mind

89 = 1.390625 * 64
 
  • #5
Hint: convert 89 to Hex.
 
  • #6
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
 
  • #7
SteamKing said:
2^64? I think you blew my mind

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

Related to Decimal to Binary 32 bit signed conversion

1. How do you convert a decimal number to its 32 bit binary representation?

To convert a decimal number to its 32 bit binary representation, you can use the following steps:

  • Step 1: Begin by writing the decimal number in binary form.
  • Step 2: Add zeroes to the left of the binary number until it is 32 bits long.
  • Step 3: If the decimal number is positive, the first bit will be 0. If it is negative, the first bit will be 1.
  • Step 4: Convert the binary number to its two's complement to represent negative numbers.

2. What is the maximum and minimum value that can be represented in 32 bit signed binary?

Using 32 bits, the maximum value that can be represented in 32 bit signed binary is 231-1, which is 2,147,483,647. The minimum value is -231, which is -2,147,483,648.

3. How does the sign bit affect the conversion from decimal to 32 bit signed binary?

The sign bit is the leftmost bit in a 32 bit signed binary number and it determines whether the number is positive or negative. If the sign bit is 0, the number is positive and if it is 1, the number is negative. The sign bit is important in the conversion because it helps to determine the range of values that can be represented in 32 bit signed binary.

4. What is the two's complement method for converting negative numbers to binary?

The two's complement method is used to convert negative numbers to binary by inverting all the bits of the positive binary representation and then adding 1 to the result. For example, to convert -5 to binary, we would first convert 5 to binary (0101) and then invert the bits (1010) and add 1 to get the two's complement representation of -5, which is 1011.

5. Can I convert a decimal number with a fractional part to 32 bit signed binary?

No, 32 bit signed binary representation is used to represent integers only. To convert a decimal number with a fractional part to binary, you can use the IEEE 754 standard for floating point representation.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
17
Views
511
  • Computing and Technology
Replies
4
Views
1K
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
14
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
13
Views
3K
Back
Top