add code examples sections
This commit is contained in:
parent
b468a02725
commit
0420f9defc
@ -40,7 +40,7 @@ myBigInt + 1n === myBigInt + 2n; // false
|
||||
|
||||
For large numbers, JavaScript provides the helper function `Number.isSafeInteger()` to test if a number is between the safe limits.
|
||||
|
||||
When you need to store a large number, use `BigInt`. `BigInt` and `Number` can be compared between them as usual (e.g. `>`, `==`), but pay attention that arithmetic operations (`+` `pass:[*]` `-` `%` `pass:[**]`) between both types raise an error unless they are converted to the same type,. Use the `BigInt` and `Number` functions to convert between both types:
|
||||
When you need to store a large number, use `BigInt`. `BigInt` and `Number` can be compared between them as usual (e.g. `>`, `==`), but pay attention that arithmetic operations (`+` `pass:[*]` `-` `%` `pass:[**]`) between both types raise an error unless they are converted to the same type. Use the `BigInt` and `Number` functions to convert between both types:
|
||||
[source,javascript]
|
||||
----
|
||||
const myNumber = Number(myBigInt);
|
||||
|
Loading…
x
Reference in New Issue
Block a user