Lisp Knowledgebase

Title: LispWorks 5 default floating point type is different from LispWorks 4

ID: 17048

Product: LispWorks
Version: 5
OS: All

When porting code to LispWorks 5 from LispWorks 4 on Windows or Linux, be aware that the default floating point format has changed.

LispWorks 5 supports the following distinct floating point types on all platforms:
short-float (same range as IEEE single precision but with fewer mantissa bits)
single-float (IEEE single precision)
double-float (IEEE double precision)

LispWorks 4 supports only one distinct floating point type on Windows and Linux:
double-float (IEEE double precision)
All other float types are equivalent to double-float.

This affects the following situations.

1. The default floating point format when reading numbers using the E exponent marker (or with no exponent marker) is controlled by the variable cl:*read-default-float-format* which defaults to single-float. In LispWorks 5 this makes a single-float, whereas in LispWorks 4 on Windows and Linux this makes a double-float.

In LispWorks 4 on Windows *read-default-float-format* is double-float, so:
(truncate 3E10) => 30000000000

In LispWorks 5 *read-default-float-format* is single-float, which cannot represent 30000000000 accurately, so the value is rounded:
(truncate 3E10) => 30000001024

If you force the value to be a double-float, then truncate works correctly, for example:
(truncate 3D10) => 30000000000

2. When calling the function float with 1 rational argument, LispWorks 5 always returns a single-float. In LispWorks 4 on Windows and Linux it returns a double-float.

See Also:
Workaround: Set cl:*read-default-float-format* to double-float or change the code to use the D exponent marker.

Patch Enhancement#:

Company     Contact     Privacy Policy     Terms of Use