-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_numbers.js
More file actions
70 lines (56 loc) · 2.07 KB
/
02_numbers.js
File metadata and controls
70 lines (56 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// 1 Number
// const num = 42 // integer
// const float = 42.42 // float\
// const pow = 10e3
// console.log('MAX_SAFE_INTEGER ', Number.MAX_SAFE_INTEGER)
// console.log('Math.pow 53', Math.pow(2, 53,) - 1)
// console.log('MIN_SAFE_INTEGER ', Number.MIN_SAFE_INTEGER)
// console.log('MAX VALUE', Number.MAX_VALUE)
// console.log('MIN VALUE', Number.MIN_VALUE)
// console.log('POSITIVE_INFINITY', Number.POSITIVE_INFINITY)
// console.log('NEGATIVE_INFINITY', Number.NEGATIVE_INFINITY)
// console.log('2 / 0', 2 / 0)
// console.log(Number.NaN) // Not A Number
// console.log(typeof NaN)
// const weird = 2 / undefined
// console.log(2 / undefined)
// console.log(Number.isNaN(weird))
// console.log(Number.isNaN(42))
// console.log(Number.isFinite(Infinity))
// console.log(Number.isFinite(42))
// const stringInt = '40'
// const stringFloat = '40.42'
// console.log(Number.parseInt(stringInt) + 2)
// console.log(Number(stringInt) + 2)
// console.log(+stringInt + 2)
// console.log('Now floats!')
// console.log(parseFloat(stringFloat) + 2)
// console.log(+stringFloat + 2)
// console.log(0.4 + 0.2) // 0.6
// console.log((2 / 5) + (1 / 5))
// console.log(parseFloat((0.4 + 0.2).toFixed(1)))
// 2 BigInt
// console.log(90071992547409919999999n - 90071992547400099999n)
// console.log(-90071992547409919999999n)
// console.log(90071992547409919999999.232323n) // error bcs that is not Int
// console.log(10n - 4) // error
// console.log(parseInt(10n) - 4)
// console.log(10n - BigInt(4))
// console.log(5n/2n)
// 3 Math
// console.log(Math.E)
// console.log(Math.PI)
// console.log(Math.pow(5, 3))
// console.log(Math.abs(-42))
// console.log(Math.min(42, 12, 23, 11, 422))
// console.log(Math.max(42, 12, 23, 11, 422))
// console.log(Math.floor(4.9))
// console.log(Math.ceil(5.1))
// console.log(Math.round(4.9))
// console.log(Math.trunc(4.9))
// console.log(Math.random())
// 4 Example
// function getRandomBetween(min, max) {
// return Math.floor(Math.random() * (max - min + 1) + min)
// }
// console.log(getRandomBetween(10, 42))