5
I intend to make an algorithm that creates prime numbers, and I need to know what the number limit is that I can have on a variable. If anyone can help me, thank you very much
5
I intend to make an algorithm that creates prime numbers, and I need to know what the number limit is that I can have on a variable. If anyone can help me, thank you very much
9
You can get this information through Number.MAX_SAFE_INTEGER
.
const maxInteger = Number.MAX_SAFE_INTEGER;
console.log(`O maior número inteiro é ${maxInteger}`);
This value represents the number 253-1. If you need larger numbers than this you can use BigInt
, which may be arbitrarily large, but take care of the support for it by the browsers.
4
The largest size of an integer is 9007199254740991
, you can check using Number.MAX_SAFE_INTEGER
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
How can I create a Bigint variaviel?
– XTRADE XTRADE
@XTRADEXTRADE There is a link to the documentation in the reply, there will have all the details of this type.
– Woss
Oh it’s now I see, Thanks bro!
– XTRADE XTRADE
Okay but look I want to convert a number 2 777232937 and I want to write it in a txt
– XTRADE XTRADE
And it gives an error where it says it cannot convert an Infinity number to Bigint
– XTRADE XTRADE
@XTRADEXTRADE You can try doing 2n**777232937n if your computer holds up...
– Woss
2 to the 777232937 is a lot, man...
– Sorack
Yeah, I know, but you can do that, right?
– XTRADE XTRADE
Anderson, what’s the point of putting 'n' in the number ?
– XTRADE XTRADE
@XTRADEXTRADE Have this described in the documentation too, read there.
– Woss