3 ms·
Rounding is fine but it would be nice if 0.1+0.2 was predictably 0.3. I am having a lot of trouble explaining to people that float numbers should be avoided unl
by rqtwteye 4y ago
Rounding is fine but it would be nice if 0.1+0.2 was predictably 0.3. I am having a lot of trouble explaining to people that float numbers should be avoided unless you really need them. I have seen code that stored versions as floats and the dev was surprised that version 1.1 wasn't always equal to "1.1".
- lifthrasiir 4y ago> I have seen code that stored versions as floats and the dev was surprised that version 1.1 wasn't always equal to "1.1". And will break when the version reaches 1.10. While I agree we need a better way to teach this (e.g. inexact-exact distinction as in Scheme or more recently Pyret), that's as problematic as storing a telephone number as an integer (or worse, a FP number).
- rqtwteye 4y agoTotally agree that storing a version in a float is stupid but that's where we are :-(