tc39 / proposal-number-fromstring

{BigInt,Number}.fromString(string, radix)
https://mathiasbynens.github.io/proposal-number-fromstring/
65 stars 7 forks source link

Number.fromString does not parse all number strings #6

Closed domenic closed 6 years ago

domenic commented 6 years ago

In particular, Number.fromString(123.456.toString()) produces 123 (or would produce an error if #5 was implemented). I'd expect 123.456.

mathiasbynens commented 6 years ago

a29f339980abb55d93f50c650294eedf071363d5 includes this change — compare step 9 in both algorithms. Please take a look and let me know of any issues.

JTBrinkmann commented 4 years ago

This proposal's motivation is stated to offer a way to invert {BigInt,Number}.prototype.toString(radix), yet the specs and README only focus on integers, despite Number.prototype.toString(radix) potentially returning string representation of non-integer numbers.

a29f339 does not "include this change", instead it causes a SyntaxError to be thrown.

I'd expect 123.456