3 ms·
Sorry to be that guy, but this doesn't work in languages that use floats: let a = 9007199254740992; let b = 1; a = a + b b = a - b a = a - b a //
by dimsumbytes 5y ago
Sorry to be that guy, but this doesn't work in languages that use floats:
let a = 9007199254740992;
let b = 1;
a = a + b
b = a - b
a = a - b
a // 1
b // 9007199254740991
- rcfox 5y agoBy the same logic, you could argue that `x++` doesn't work work for floats. As long as your intermediate values stay between `Number.MAX_SAFE_INTEGER` and `Number.MIN_SAFE_INTEGER`, you'll be fine.
- dimsumbytes 5y agoAgain, not trying to be that guy, but technically it still breaks: a = -0.0 b = 0.0
- jayceedenton 5y agoI think you might be that guy :)