Hi,
there are a number of mistakes in this method, see by yourself:
{
WebUtils jsonNumberFrom: '1.e-1' readStream.
WebUtils jsonNumberFrom: '1.e+1' readStream.
WebUtils jsonNumberFrom: '1e1,1e2' readStream.
WebUtils jsonNumberFrom: '1e+,1e2' readStream.
WebUtils jsonNumberFrom: '1e-,1e2' readStream.
WebUtils jsonNumberFrom: '1.1e30' readStream.
}
First one because we compare ascii value (an Integer) to $- (the Character)...
2nd one same for +
Third one because we decide to do nothing when exponent = 1
4th and 5th are variations of 1st and 2nd
Moreover, the conversions are subject to double rounding problem (it main chain up to 3 inexact operations), it will thus fail to answer the nearest Float to some json string. This is bad, ECMA script does not make such mistake.
self assert: (
WebUtils jsonNumberFrom: '1.1e30'
) = 1.1e30
There is no use to get a false result fast IMO...