Login

Decimal Floating Point

Decimal Floating Point

Anselm has first class support for decimal arithmetic via the Anselm.decimal type function.

Decimal float literals have the following syntax 123.456d+789. Unlike binary floats, the exponent suffix is not optional. Like all Anselm scalar literals, decimal literals can be overloaded. The standard basis library defines a few special custom literals for working with IEEE 754-2008 standards such as 1.2d+0d32, 3.4d+0d64, 5.6d+0d128 for Decimal32, Decimal64, and Decimal128 formats, respectively.

Background information

Mike Cowlishaw's site contains a nice overview of decimal arithmetic for computers.