Mașina de scris bigint vs numărul

Exemple de cod

0
0

mașina de scris bigint vs numărul

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

Pagini similare

Pagini similare cu exemple

În alte limbi

Această pagină este în alte limbi

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