This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// like parseFloat, but takes an optional radix | |
function parseFloatWithRadix(s, r) { | |
r = (r||10)|0; | |
const [b,a] = ((s||'0') + '.').split('.'); | |
const l1 = parseInt('1'+(a||''), r).toString(r).length; | |
return parseInt(b, r) + | |
parseInt(a||'0', r) / parseInt('1' + Array(l1).join('0'), r); | |
} | |
// like Number..toFixed, but takes an optional radix |
OlderNewer