IEEE Floats

IEEE-Floats provides a way of converting values of type float and double-float to and from their binary representation as defined by IEEE 754 (which is commonly used by processors and network protocols).

The library defines encoding and decoding functions for the common 32-bit and 64-bit formats, and a macro for defining similar functions for other formats. The default functions do not detect the special cases for NaN or infinity, but functions can be generated which do, in which case the keywords :not-a-number, :positive-infinity, and :negative-infinity are used to represent them.

Download and installation

IEEE-Floats is released under a BSD-style license. The latest release can be downloaded from, or installed with asdf-install.

A darcs repository with the most recent changes can be checked out with:

> darcs get

Or look at it online.

Support and mailing lists

The ieee-floats-devel mailing list can be used for any questions, discussion, bug-reports, patches, or anything else relating to this library. You can also e-mail the author/maintainer, Marijn Haverbeke, directly.


function encode-float32 (float) => integer

Convert a float into its 32-bit binary representation.

function decode-float32 (integer) => float

Create a float from a 32-bit binary representation.

function encode-float64 (float) => integer

Convert a float into its 64-bit binary representation.

function decode-float64 (integer) => double-float

Create a float from a 64-bit binary representation.

macro make-float-converters (encoder-name decoder-name exponent-bits significand-bits support-nan-and-infinity-p)

Writes an encoder and decoder function for floating point numbers with the given amount of exponent and significand bits (plus an extra sign bit). If support-nan-and-infinity-p is true, the decoders will also understand these special cases. NaN is represented as :not-a-number, and the infinities as :positive-infinity and :negative-infinity. Note that this means that the in- or output of these functions is not just floating point numbers anymore, but also keywords.

Back to

Valid XHTML 1.0 Strict