4 ms·
I love NaNs, especially their "infectious" quality. Initializing float variable to NaNs before first assignment can make a lot of errors immediately obvious.
by PopePompus 5y ago
I love NaNs, especially their "infectious" quality. Initializing float variable to NaNs before first assignment can make a lot of errors immediately obvious. I wish there were a NaN for integers.
- saagarjha 5y agoDon’t initialize them and turn on UBSan :)
- colejohnson66 5y agoWhat about a “nullable” double? In C#, you’d use `double?`, Rust would be Option<f64>, C++ would be std::optional<double>. Then any operation would throw upon an unset value?
- olliej 5y agoThat would required every operation on a floating point value to return an optional, which you’d then need to unwrap and branch on.