filmov
tv
28. JavaScript Numbers

Показать описание
In modern JavaScript, there are two types of numbers:
1. Regular numbers in JavaScript are stored in 64-bit format IEEE-754;
2. BigInt numbers, to represent integers of arbitrary length.
This video plan:
- How to write a number
- Hex, binary and octal numbers
- toString()
- Rounding
- Imprecise calculations
- Parse number
How to write a number:
1.23e6 === 1.23 * 1000000
1.23e-6 === 1.23 / 1000000 === 0.00000123
Hex, binary and octal numbers:
hex: 0xff === 0xFF === 255
octal: 0o377 === 255
binary: 0b11111111 === 255
toString():
255..toString(2) == 0b11111111
255..toString(16) == ff
Rounding:
removes anything after the decimal point without rounding: 3.1 becomes 3, -1.1 becomes -1.
Let's be friends:
1. Regular numbers in JavaScript are stored in 64-bit format IEEE-754;
2. BigInt numbers, to represent integers of arbitrary length.
This video plan:
- How to write a number
- Hex, binary and octal numbers
- toString()
- Rounding
- Imprecise calculations
- Parse number
How to write a number:
1.23e6 === 1.23 * 1000000
1.23e-6 === 1.23 / 1000000 === 0.00000123
Hex, binary and octal numbers:
hex: 0xff === 0xFF === 255
octal: 0o377 === 255
binary: 0b11111111 === 255
toString():
255..toString(2) == 0b11111111
255..toString(16) == ff
Rounding:
removes anything after the decimal point without rounding: 3.1 becomes 3, -1.1 becomes -1.
Let's be friends: