View Full Version : Understanding floating point

05-09-2003, 04:29 PM
I just got burned at a programming competition for not knowing the various functions related to precision/rounding floating point values. </background>
Anyhow, i'm having trouble finding an explanation of how floating point numbers are represented in memory, and the arithmetic behind them. (Something about "mantissa" and "base"?)

If anyone could help me out that'd be great. (Yes, I already searched google)
Gawd, i'm such a jackass.

05-09-2003, 05:03 PM

05-09-2003, 05:07 PM

I learned about that in an architecture course last year. (mantissa sounded familiar, but I dont remember much about FPNs)

It was under a chpater called Data Representation. I searched google for Data Representation + Floating-Point Numbers, and came up with that link.

05-09-2003, 08:23 PM

05-10-2003, 03:16 AM
Here's a tutorial on floating point.


Here's some info, also about the IEEE standard on floating point.


05-11-2003, 03:01 PM
I wrote a printf function in assembly which had to deal with floats like that (because I couldn't get the FPU code to work... :mad:)

You have one sign bit, positive or negative. The rest are divided into the mantessa and the exponent. (Remember that bits are represented using 1 and 0.)

Using their version of scientific notation, you come up with numbers like these:
1.001110110 x 2^111011
The 1 in the one's column exists for all possible numbers, so it's left out. Just the number part after the decimal point is left. The exponent is the number after "2^". (2^ is redundant also).

05-11-2003, 03:58 PM
I couldn't remember how to format floats using C++ streams, so with about 1 minute left I got a bright idea to try printf... it worked, but I didn't submit it in time. Cost me $1000 scholarship :(

Anyhow, those links are perfect. Thanks everyone.