Fable icon indicating copy to clipboard operation
Fable copied to clipboard

float32 arithmetics

Open kerams opened this issue 4 years ago • 1 comments

Description

Arithmetic operations on a float32 may produce numbers that are only representable as float64.

Repro code

This prints

2.7
2.7

but 2.7 is not a number that is representable as float32. On .NET, the same code prints

2.7
2.700000048f

Doing Math.fround(2.7) in the console returns 2.700000047683716, which corresponds to the .NET float32. Shouldn't all float32 operations, not just literals, be wrapped in an fround?

Related information

  • Fable version: 3.4.10 in the REPL

kerams avatar Dec 10 '21 19:12 kerams

Probably... tbh I haven't paid a lot of attention to having proper arithmetic with .net numeric types 😅 Most of the work on this regard has been done by @ncave

alfonsogarciacaro avatar Dec 15 '21 01:12 alfonsogarciacaro