Created
August 18, 2024 08:15
-
-
Save dfkaye/59ab4fcbbbc2ee444d01454db4ce96a6 to your computer and use it in GitHub Desktop.
parse bigint
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
// 1 July 2024 | |
// parseBigInt | |
function parseBigInt(b, r) { | |
var n = String(b).split("n")[0]; | |
return parseInt(n, r); | |
} | |
var base10 = ["2n.3", "5.5", "FFnA", "n.3"].map(function (v, i) { | |
return parseBigInt(v, 8); | |
}); | |
var base16 = ["9n.3", "15.5", "FFnA", "n.3"].map(function (v, i) { | |
return parseBigInt(v, 16); | |
}); | |
var bigInts = [ BigInt(54321), BigInt(121345) ]; | |
[].concat(base10, base16, bigInts).join(", "); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment