This code snippet provides methods to convert between various ieee754 floating point numbers format. For example double precision to single precision. The format is given by a pair (w, p) giving the size in bits of the exponent part and the significand part in the ieee754 representation of a number (these are (11, 52) for a standard 8 byte float and (8, 23) for a single precision float, but the snippet allows exotic sizes like (3, 4) or (9, 47)). Conversion to and from python floats are provided, given that your architecture's python floats have 8 bytes. Python >= 2.7 is required.
Edited 2 Years Ago by Gribouillis: documentation bugfix