lossy_float_literal
Finds a float32 literal with more digits than a float32 keeps (31415.92653).
Category style, warn by default.
#import "Basic";
main :: () {
scale: float32 = 16777.2171234;
print("%\n", scale);
}warning[lossy_float_literal]: `16777.2171234` has 12 significant digits, but a `float32` keeps 8
--> example.jai:4:22
|
4 | scale: float32 = 16777.2171234;
| ^^^^^^^^^^^^^
|
help: write `16777.217`, which is the same `float32`
|
4 ~ scale: float32 = 16777.217;
|
= note: `lossy_float_literal` is `warn` by default#import "Basic";
main :: () {
scale: float32 = 16777.217;
print("%\n", scale);
}A float32 keeps about seven decimal digits. Digits past the shortest spelling that reads back as the same float32 change nothing and suggest a precision the program does not have.