Answer the question
In order to leave comments, you need to log in
How to convert a large array of numbers to a single number?
Let's say it has an array like this:
let array = [9, 2, 2, 3, 3, 7, 2, 0, 3, 6, 8, 5, 4, 7, 7, 5 , 6,7,7];
How can it be converted to a single number? - 9223372036854775677
Is there any shorthand method to implement this question? It didn’t work through Number, because it has limitations. It’s possible through BigInt, but I still haven’t figured out how to implement it.
Answer the question
In order to leave comments, you need to log in
The fact is that
console.log(Number.MAX_SAFE_INTEGER)
//9007199254740991
const array = [9, 2, 2, 3, 3, 7, 2, 0, 3, 6, 8, 5, 4, 7, 7, 5 , 6,7,7];
const number = BigInt(array.join(''));
console.log(number.toString());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question