proposal-number-fromstring
proposal-number-fromstring copied to clipboard
fractional part
Is fractional part allowed? example:
Number.fromString('3.14159', 10) // => 3.14159
Number.fromString('100.11', 2) // => 4.75
Number.fromString('202.1', 3) // => 20.33333333333333
Number.fromString('ff.4', 16) // => 255.25
The readme says
It accepts only strings that can be produced by {BigInt,Number}.prototype.toString(radix = 10), and throws an exception for any other input.
so since eg 4.75.toString(2) === '100.11' then yes, those should all work.
that's what I assumed, but as the readme only gives examples with integers, it's not very obvious.
dot (.) is not mentioned in spec:
- If string represents a mathematical number value in radix-R notation, using the characters 0-9 for digits with values 0 to 9, and the letters a-z for digits with values 10 through 35, then