it occurs to me that we could give a warning if you write a float literal whose integer part is so big it's going to be represented as something else.
For example, if you write 9007199254740993.0f64 it will actually be represented as the equivalent of 9007199254740992.0f64 .
the only downside I can think of to having a warning for this is that maybe you have some constant that you know is going to be imprecise but you want to write it that way anyway because that's how it occurs in nature or something? But I guess then you could still note that in a comment.
Any thoughts on this idea?
Sounds like a friendly compiler feature to me.
I think it should definitely print out the exact literal that you can copy and paste to get rid of the warning. If you do need this precision you don't want ci to fail due to the failure exit code.
Wouldn't this sometimes result in numbers whose closest floating point representations can only be represented using a non-terminating decimal expansion? In those cases, there'd be no way to "correct" the number literal in the file.
hm, any floating point value that can be represented in memory should be representable precisely in syntax as far as I know, so I think we should be ok!
In c# there's Errors, Warnings and Infos. Could we have ℹ️ Info in roc? My rationale is that warnings and errors should fail your CI, but Infos wouldn't. As you mentioned above, if there is an edge case where indeed the user wants the unrepresentable float on their codebase (for whichever reason), roc would print it as a compilation info but not fail the build. Would that make sense?
If there's a compiler message that's shown but doesn't fail CI, then people will merge it into main, and development will get noisier and noisier over time.
If it truly should never be fixed, then there would need to be a way to disable the warning in source code.
yeah I generally agree with that. I think either the compiler should be silent about it, or else fail CI because you should fix it.
I feel like this would rather be an optional warning (maybe only seen with check or something) cause it may confuse people when they see the wrong value. I guess you can just add a comment for everything.
Also, why only giant floats? This technically is a problem with all floats. A large float losing values at the end is the same as a fractional float losing values at the end.
Also, if you use the giant float, it won't work as expected in many cases, so falls into the category of normal float errors. May give users incorrect confidence if we warn them to just change the value.
For example what is 9007199254740992.0f64 + 1?
...Hopefully I typed that float right.
that's a fair point
Last updated: Jun 16 2026 at 16:19 UTC