Our first data type!
(And every other data type.)
What values can be represented.
What the syntax is for writing them in our langauge.
What we can do with them.
Numbers are infinite.
Computers are finite.
What to do?
Javascript uses a format that is well supported by modern computers, called binary floating point.
Basically scientific notation for computers.
It can represent integer values from -253 to 253 (-9,007,199,254,740,992 to 9,007,199,254,740,992)
It can represent decimal values and very large numbers with approximately 15 decimal digits of precision.
It can also represent very small numbers near zero with greater precision.
We don’t really have to worry about it. 🎉
(Most of the time.) 🤨
0
1
2
3
1000000000
1_000_000_000
9_007_199_254_740_992
Nine quadrillion seven trillion one hundred ninety-nine billion two hundred fifty-four million seven hundred forty thousand nine hundred ninety-two
-1
-2
0.0
1.2
-0.5
1.4142135623730951
(Best approximation of the square root of 2)
2.718281828459045
(Best approximation of e)
3.141592653589793
(Best approximation of π)
1.7976931348623157e+308
(Biggest number we can represent.)
1.7976931348623155e+308
(The second biggest number we can represent.)
The gap between it and the biggest is 1.99584030953472e+292
2.220446049250313e-16
5e-324
Infinity
NaN
Math, mostly.
A lot of programming is about combining smaller pieces into bigger pieces.
Expressions are a way of combining values (like numbers) with operators to produce new values.
The exact operators depend on the types of the values.
+
-
*
/
%
**
Note, this is an approximation.
wtf?!
Uh, oh. That’s not right. 💩
Should be 36028797018963968
Would be better as 3.602879701896397e16
Individual numbers are values.
Expressions combine numbers to produce new values.
12345
12_345
12345.00
1.2345e4
1
43 / 43
(108 - (2 ** 3)) * 0.01
We’ll talk more later about what you can do with values.