Numbers

JavaScript has a single number type. Internally, it is represented as 64-bit
floating point, the same as Java's double. Unlike
most other programming languages, there is no separate integer type, so 1 and 1.0 are the
same value. This is a significant convenience because problems of overflow in short
integers are completely avoided, and all you need to know about a number is that it
is a number. A large class of numeric type errors is avoided.



If a number literal has an exponent part, then the value of the literal is
computed by multiplying the part before the e by
10 raised to the power of the part after the
e. So 100
and 1e2 are the same number.
Negative numbers can be formed by using the -
prefix operator.
The value NaN is a number value that is the
result of an operation that cannot produce a normal result. NaN is not equal to any value, including itself. You can detect
NaN with the isNaN(
number
) function.
The value Infinity represents all values
greater than 1.79769313486231570e+308.
Numbers have methods (see Chapter 8). JavaScript has a Math object that contains a set of methods ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access