When converting a string to a float with an exponent E (eg. 42e+9), Float::atof() is very permissive of what the first character can be after that 'e'/'E'.
For example (float) "42ea" produces 4.2e+50, and ({ sscanf("42ea b", "%f%s", a, b), a, b }) returns ({ 2, 4.2e+50, " b"}) (note sscanf() internally uses the same Float::atof()).
The LPC compiler will treat 42ea as error (that is, it treats the "ea" portion as a separate token which then fails), so I'd expect casting strings to do the same. Likewise, I'd expect the latter expression to instead return ({ 2, 42.0, "ea b" }).
I've written a possible solution to this to help identify where the issue is.
(As usual, above was tested using latest dgd + cloud server, and can be tested through admin 'code' command.)
When converting a string to a float with an exponent E (eg. 42e+9), Float::atof() is very permissive of what the first character can be after that 'e'/'E'.
For example
(float) "42ea"
produces4.2e+50
, and({ sscanf("42ea b", "%f%s", a, b), a, b })
returns({ 2, 4.2e+50, " b"})
(note sscanf() internally uses the same Float::atof()).The LPC compiler will treat
42ea
as error (that is, it treats the "ea" portion as a separate token which then fails), so I'd expect casting strings to do the same. Likewise, I'd expect the latter expression to instead return({ 2, 42.0, "ea b" })
.I've written a possible solution to this to help identify where the issue is.
(As usual, above was tested using latest dgd + cloud server, and can be tested through admin 'code' command.)