[racket-dev] Single-precision floats

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Wed Jan 5 17:14:54 EST 2011

Single and double precision floating-point numbers have different read
syntax but print the same way.

Welcome to Racket v5.0.99.6.
> 1.0e0
> (flonum? 1.0e0)
> 1.0f0
> (flonum? 1.0f0)

Is this a bug?

Also, it seems there's no read syntax for single-precision specials
(nan and infinities), even though they exist.

> +nan.0
> (flonum? +nan.0)
> (/ 0.0f0 0.0f0)
> (flonum? (/ 0.0f0 0.0f0))

I could add +nan.0f0 (or any exponent) and others. For symmetry, I
could also add +nan.0e0 and others as syntax for double-precision

It would also be nice to have conversion functions to convert between
the two kinds of floating-point numbers.

If nobody objects, I'll implement that.


Posted on the dev mailing list.