3 ms·
> If the sort function decides those strings look like numbers it may coerce them into doubles (ints being too small to hold them). You sometimes even see that
by TacticalCoder 5y ago
> If the sort function decides those strings look like numbers it may coerce them into doubles (ints being too small to hold them).
You sometimes even see that with APIs inconsistently wrapping behind quotes or not (seemingly at random) some values. And then it gets trickier because you can have the parser correctly parse into, say, "big decimals" some of the values, while others may be automagically, imprecisely, parsed into floating-point numbers.
The problem is of course made worse by people overall overusing decimal numbers where integers would be totally fine.
One of the most beautiful floating-point bugs ever is this one (from about ten years ago as I recall it): language preference in browsers could be set as a decimal number between 0 and 1. Java (and other languages) had a broken floating-point implementation where parsing a certain floating-point number would lead to an infinite loop. So you could set one core of any webserver with that bug by simply requesting a page, with the language preference set to that floating-point number. Rinse and repeat a few times and all cores were spinning at 100%, effectively DDoS'ing the webserver.