The Floating Point Explorer

Back To Tips Page

In a recent thread there was an extended discussion about floating point representation issues.  To allow people to study floating point, I created the Floating Point Explorer.  This little program allows the user to set the bits of the floating point number and see what the converted representation is, or type in a floating point number and see what it converts to.  It also allows the computation of results based currently on add, subtract, multiply and divide.

The screen is divided into several sections.  The upper part of the screen deals with the representation of a double.  The 64 check boxes represent the 64 bits of a double, shown in binary.  The high-order bit is the sign.  The next 11 bits are the exponent value, and the remaining 52 bits are the mantissa.

The Set All and Clear All buttons will set all the bits of the exponent or mantissa.  The 20 button sets the exponent to represent 20

The Value edit control and associated spin control show and allow you to modify the exponent value, which is allowed to be in the range of 0..2047.  However, the more natural represention would be the excess-1024 representation.  Thus 0 given in the Excess-1024 control represents the absolute numeric value in the exponent of 1024.

The representation also allows you to see the hexadecimal value of the mantissa, and edit it by changing the hex value displayed.

There are four buttons to select specific representations, such as +inf, -inf, +Nan and -NaN.  For the NaN representations, an exponent of all 1s and a nonzero mantissa is a NaN, and I arbitrarily chose to set the low-order bit of the mantissa to represent these values.  You can experiment with other bits.

Together, all of these controls allow you to manipulate what is called the number

The large vertical arrow buttons pointing downward transfer a value from the number to one of the three "working registers" designated n1, n2 and n3. The large upward pointing arrows transfer a value from one of the working registers to the number, so it can be examined in detail.

The horizontal arrow buttons transfer a value from the working register below them to one of the other working registers. 

The operation buttons perform the indicated operation n3 = n1 op n2

A typical sort of test might involve typing  value into n1 (for example, 80), typing a value into n2 (for example, 100) and performing an operation such as division, seeing the result in n3.  Then the large up-arrow above n3 is clicked to transfer the result back to the number so its representation can be examined.

In terms of formatting, this also allows you to see the effects of the various formatting options.  The Format options allow selection of the flags, the width, the precision, and the type.  The formatting is shown to the left of the Format box.  The format can be associated with the display of n1, n2, n3 or the number by clicking one of the small arrow buttons.

download.gif (1234 bytes)

[Dividing Line Image]

The views expressed in these essays are those of the author, and in no way represent, nor are they endorsed by, Microsoft.

Send mail to with questions or comments about this web site.
Copyright 1999-2007 FlounderCraft, Ltd.,  All Rights Reserved.
Last modified: May 14, 2011