• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Floating Point Binary (single precision)

Qua Sar

n00b
Joined
Dec 2, 2008
Messages
15
Hello,
I have a homework and an example but i can't make sense of it. I am suppsoed to take -15 and 15/16 into floating point binary single precision... i'm not sure how to get the exponent or mantissa (Fraction) from -15 or 15/16 ... do any of you guys remember how to do this and can help me out?
 
I'll give you an example of converting a decimal number to a binary representation.

Decimal: 5.75

You take what's right of the decimal (.75) and multiply that by 2 until you get 0.0.

.75 x 2 = 1.5
.5 x 2 = 1
.0 x 2 = 0

Now we need to put the decimal 5 into binary representation.

Instead of multiplying by 2, we divide by 2 and take the remainder.

5/2 = 2 R 1
2/2 1 R 0
1/2 0 R 1

The binary representation of 5 is 101.

Now we combine the two keeping the decimal in place so we get:
101.11


I'll take this one step further and convert 5.75 to an IEEE754 32-bit binary format.

So we know we have 101.11 as the binary representation.
Now we need to move the decimal two places to the left so we have our hidden bit (always 1). It's going to look like this: 1.0111 x 2^2. We get 2^2 because it's in binary format and we moved the decimal two places. If we moved it three places, it'd be 2^3 and so forth.

Seeing as how we're converting 5.75 to a 32-bit binary format, we know the bias is 127.

Getting the sign bit is easy because it's either 1 or 0. This number is positive so our sign bit is 0. Negative numbers will have a sign bit of 1.

To get the exponent, we take the bias and add the exponent. In this case, we add 127+2 = 129. Now we break down 129 into binary format so we get 10000001. And the significand is everything right of the decimal: 01110000000000000000000

So the final answer is 0 10000001 01110000000000000000000.

I hope this helps.
 
Ah, this brings back memories of my computer architecture class. I think I was the only computer engineer in the class that didn't hate this stuff.
 
Thanks so much guys, once you did the 5.75 to binary the rest of it came back to me. I haven't done this since freshman yea and i am a junior now in microcomputer architecture, so i was very annoyed when i had forgotten how and that i couldn't find a clear example on how do to do it. Thanks so much!
 
Back
Top