Should float literals outside of the representable range produce a type error?

If you try to create an int literal that is larger or smaller than what fits into 32bits you receive a type error

Integer literal exceeds the range of representable integers of type int

Playground: https://rescript-lang.org/try?code=DYUwLgBAHhC8EFYnJUA

Should a similar error be added for float literals?

1 Like

Note float covers from -Infinity to Infinity. It is common that some floats are not precise in IEEE754 encoding. In that case, there is no such thing for floats that exceeds the range

JS numbers aren’t arbitrary precision, you can only fit so many digits in the ~53 bits that JS affords floats. There are values (known at compile time in the case of literals) that will be rounded/clamped, I think?