In certain situations, it even disallows making assumptions about equality and ordering between floats.
I'm guessing it does this when you define both floats in the same location with constant values.
The correct way to compare floats whose values you don't know ahead of time is to compare the absolute of their delta against a threshold.
i.e.
abs(a - b) <= 0.00001
The idea being that you can't really compare floats due to how they work. By subtracting them, you can make sure the values are "close enough" and avoid issues with precision not actually mattering all that much past the given threshold. If you define 2 constant values, though, the compiler can probably simplify it for you and just say "Yeah, these two should be the same value at runtime".
Rust has a warning (has it been promoted to error? I think it was supposed to be) about comparing floats. Nothing to do with same being const. You basically don't have an equality operator for them
Way too late for that. Every language I know makes some kind of auto conversion for numeric comparisons... and sometimes for strings as well.
I know of Rust, which is pedantic enough to not allow comparing integers to floats directly.
In certain situations, it even disallows making assumptions about equality and ordering between floats.
I'm guessing it does this when you define both floats in the same location with constant values.
The correct way to compare floats whose values you don't know ahead of time is to compare the absolute of their delta against a threshold.
i.e.
abs(a - b) <= 0.00001
The idea being that you can't really compare floats due to how they work. By subtracting them, you can make sure the values are "close enough" and avoid issues with precision not actually mattering all that much past the given threshold. If you define 2 constant values, though, the compiler can probably simplify it for you and just say "Yeah, these two should be the same value at runtime".
Rust has a warning (has it been promoted to error? I think it was supposed to be) about comparing floats. Nothing to do with same being const. You basically don't have an equality operator for them