稿bigint vs数

代码示例

0
0

稿bigint vs数

1. BigInt is an integer, number is a decimal
  //bigInt
  var BigNum1=100n;     	//ok
  var BigNum2=100.20n;    //error
  //number
  var Num1=100;           //ok
  var Num2=100.20;        //ok

2. Different implementation
The number can handle numbers up to 9007199254740991.
The BigInt can handle arbitrary long numbers, limited by the available memory of the system.

3. BigInt cannot be used in arithmetic operations with numbers
  let numVar=100;
  let bigVar= 100n;
  console.log(numVar+bigVar); // error

4. ...but you can compare them
  console.log(1n < 2)     //true
  console.log(2n > 1)     //true
  console.log(2n > 2)     //false
  console.log(2n >= 2)    //true

5. More details on the source

类似页面

带有示例的类似页面

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................