4 ms·
3.9e3 is equivalent to 3900 in the same way that 3,900 is equivalent to 3900. So, Ruby’s number parsing is garbage I guess. Hopefully it at least does this pro
by avalys 4y ago
3.9e3 is equivalent to 3900 in the same way that 3,900 is equivalent to 3900.
So, Ruby’s number parsing is garbage I guess. Hopefully it at least does this properly for floats?
- padseeker 4y agoWith ROR it might be transformed via the params parser. If you enter the code below in plain old Ruby environment, like irl or the console, it will properly parse it; "3.9e3".to_f => 3900.0 Something happens when submitting web based params. I'd be curious to see what other back end languages and frameworks do.
- radiospiel 4y agoThis is what happens: "3.9e3".to_i => 3 and Integer("3.9e3") raises "invalid value for Integer()". Really, nothing to see here. Ruby just doesn't treat "3.9e3" as a valid string for an integer (which arguably is correct IMHO)
- Flimm 4y agoSome countries use a comma as the decimal point. So it's not obvious to everyone that 3,900 == 3900