#1,089 – How 32-Bit Floating Point Numbers Are Stored in .NET, part II

(part I)

We store the sign, exponent, and mantissa of a binary floating point number in memory as follows.

The sign is stored using a single bit, 0 for positive, 1 for negative.

The exponent is stored using 8 bits.  The exponent can be positive or negative, but we store it as a positive value by adding an offset (bias) of 127.  We add 127 to the desired exponent and then store the resulting value.  Exponents in the range of -126 to 127 are therefore stored as values in the range 1 to 254.  (Stored exponent values of 0 and 255 have special meaning).

Because we normalize the binary floating point number, it has the form 1.xxx.  Since it always includes the leading 1, we don’t store it, but use 23 bits to store up to 23 digits after the decimal point.

For example:






About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #1,089 – How 32-Bit Floating Point Numbers Are Stored in .NET, part II

  1. Pingback: Dew Drop – May 5, 2014 (#1769) | Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: