Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to...
by spacechild1 on Wednesday May 10, 2023 @04:35AM
(#35885097)
True, but it's an easy mistake to make.
[ Parent
| on HN ]
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to...
by tialaramex on Wednesday May 10, 2023 @08:13AM
(#35886223)
It's an easy mistake to make in C (and C++) because of their lackadaisical approach to type safety.
In Rust if we insist we want to compare an f32 (what C would call float) to an f64 (double), the language says it doesn't have a way to do that, highlighting our mistake. If we just try to compare an f32 with value 0.7 against 0.7, the type inference concludes 0.7 is also an f32 so it's equal, and if we do the same with an f64, this time by inference 0.7 is an f64 and so again it's equal.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to...
by spacechild1 on Thursday May 11, 2023 @06:00AM
(#35900017)
Rust's behavior makes so much more sense! IMO, implicit conversions is one of C++ biggest weaknesses. Yes, it may save some keystrokes, but it can easily lead to subtle (or not so subtle) bugs.