The integrated cross-platform development tool for ANSI Common Lisp LispWorks logo

Lisp Knowledgebase

Title: Floats are read with single precision by default

ID: 17053

Product: LispWorks
Version: All
OS: All

Description: Floating point numbers are read by default as single-float values. This is the default Common Lisp behavior (see

The single-float type has only 23 bits in the mantissa, resulting in apparent loss of precision for some numbers such as

(- 605113171.148 605113170.148) => 0.0

However, if you force these numbers to be read as double-float, then the form returns the expected result, for example:

(- 605113171.148d0 605113170.148d0) => 1.0D0

Note: LispWorks 4 on Windows and Linux has a different default behavior. See other article for details.

See Also: (link)

Patch Enhancement#:

Top | Back