A Python module to simulate binary floating point representation to IEEE 754 standards of arbitrary fixed precision, or to infinite precision.

I have written a module to simulate the machine representation of binary floating point numbers and their arithmetic. Values can be of arbitrary fixed precision or infinite precision, along the same lines as the decimal class. The design is loosely based on the decimal module, although it doesn't get in to threads, for instance. You can play with different IEEE 754 representations with different precisions and rounding modes, and compare with infinite precision Binary numbers. For instance, it is easy to learn about machine epsilon, representation/rounding error using a much simpler format such as a 4-bit exponent and 6-bit mantissa. Such a format is easily defined in the new module and can be manipulated easily.

Documentation and basic examples can be found in the docstring of simfloat.py (the text at the top of the file).

Currently, the code is kept up to date via SVN as part of the EconPy package.

Source files:


More details of the theory in these pages, and references therein:

Floating point
IEEE 754 standard
Binary numeral system