# .args. -number:float32 """ On MS .NET 2.0, float32 seems to be psychic and can store and add 0.1 perfectly, even though its big brother, float64, cannot! Well I think it's just a rounding issue. Interestingly, Mono gives slightly different results even on the same hardware. All the more reason to prefer decimal. I checked the code gen and the System.Single type is definitely in use. The assertions below prove the imperfect arithmetic whether on .NET or Mono. """ use System.Globalization class X shared def main x as number = 1 assert x == 1 x = 2 assert x == 2 x = 3.0 assert x == 3 assert x == 3n assert x == 3.0 x = 3n assert x == 3 assert x == 3n assert x == 3.0 x = 4.5 assert x == 4.5 f = 0.1 one = f + f + f + f + f + f + f + f + f + f pointNine = f + f + f + f + f + f + f + f + f assert 1.0 <> one or 0.9 <> pointNine assert one.toString('R', CultureInfo.invariantCulture) == '1.00000012' or pointNine.toString('R', CultureInfo.invariantCulture) == '0.900000036' i = 1 j = 2 x = i / j assert x == 0.5 x = 3.0 y = 4.0 assert .checkNumber(x, y) == 7.0 assert .checkNumber(x, y) == 7.0f32 assert .checkFloat32(x, y) == 7.0f32 def checkNumber(a as number, b as number) as number return a + b def checkFloat32(a as float32, b as float32) as float32 return a + b