Floating point bugs in Spin2
Besides the misparsing of "-1.0" as "-(1.0)" (which could be argued is a feature, but it's certainly a surprise) there is also a pervasive confusion in Spin2 between NaN (not a number) and infinity.
The IEEE encoding specifies that infinity is encoded as $7f80_0000, and that numbers $7f80_0001 - $7fff_ffff are NaN. Spin2 seems only to have a single NaN ($7fff_ffff) and also returns this for many cases that should yield infinity.
The following program illustrates some of these problems:
con _clkfreq = 180_000_000 debug_baud = 2_000_000 pub main() | minus_zero, bignum, x, y, inf1, real_inf minus_zero := $8000_0000 bignum := $7f7f_ffff ' largest representable IEEE single real_inf := $7f80_0000 ' IEEE infinity inf1 := bignum /. 0.0 DEBUG("float test") if inf1 <> real_inf DEBUG("ERROR:", fdec(inf1), " and ", fdec(real_inf), " should both be infinity") x := bignum *. 2.0 if x <> real_inf DEBUG("ERROR: ", fdec_(bignum), " *. 2.0 should be infinite but got ", fdec(x), " : ", uhex_(x)) x := 1.0 /. real_inf if x <>. 0.0 DEBUG("ERROR: 1.0 /. infinity should give 0.0 got ", fdec(x), " : ", uhex_(x)) DEBUG("done test")