D
Dr J R Stockton
Some may not have noted that Number.toString(16) handles non-integers.
Math.PI.toString(16) -> 3.243f6a8885a3
1e44.toString(16) -> 47bf19673df53000000000000000000000000
Math.random().toString(2) => 0 . /[01]{1,53}/
ECMA 262 (5) 15.7.4.2 Number.prototype.toString ( [ radix ] )
makes no mention of non-integers.
A Hex integer string H can be turned into a Number by
+ ( "0x" + H )
but that does not work for a Hex fraction string. Is there in fact an
easy built-in way of converting non-integer Hex strings to Number?
Otherwise, I suggest that ECMA 6 should specify a Method whereby for ANY
Number X the result of X.toString(B) can be converted to the original X
(disregarding the sign of zero).
Math.PI.toString(16) -> 3.243f6a8885a3
1e44.toString(16) -> 47bf19673df53000000000000000000000000
Math.random().toString(2) => 0 . /[01]{1,53}/
ECMA 262 (5) 15.7.4.2 Number.prototype.toString ( [ radix ] )
makes no mention of non-integers.
A Hex integer string H can be turned into a Number by
+ ( "0x" + H )
but that does not work for a Hex fraction string. Is there in fact an
easy built-in way of converting non-integer Hex strings to Number?
Otherwise, I suggest that ECMA 6 should specify a Method whereby for ANY
Number X the result of X.toString(B) can be converted to the original X
(disregarding the sign of zero).