HTML and CSS Reference
Using Number Constants and Different Bases. The constants MAX_VALUE ,
MIN_VALUE , NEGATIVE_INFINITY , POSITIVE_INFINITY , and NaN are properties of
the Number() function, but are not used with instances of the Number object; thus, var
huge = Number.MAX_VALUE is valid, but huge.MAX_VALUE is not. NaN is a special
value that is returned when some mathematical operation results in a value that is not
The methods provided to the Number object manipulate instances of number objects.
For example, to convert numbers to strings representing different bases, the toString()
method manipulates a number, either primitive or object. See Example 9.31.
<body bgcolor="orange"><font color="black" size="+1">
var largest = Number.MAX_VALUE;
var smallest = Number.MIN_VALUE;
var num1 = 20; // A primitive numeric value
var num2 = new Number(13); // Creating a Number object
document.write("<b>The largest number is " + largest
+ "<br />");
document.write("The smallest number is "+ smallest
+ "<br />");
document.write("The number as a string (base 2): "+
document.write("<br />The number as a string (base 8): "+
document.write("<br />The square root of -25 is: "+
Math.sqrt(-25) + "<br />");
The constant MAX_VALUE is a property of the Number() function. This constant
cannot be used with an instance of a Number object.
The constant MIN_VALUE is a property of the Number() function.
A number is assigned to the variable called num1 .
A new Number object is created with the Number() constructor and assigned to
num2 . It is easier to use the literal notation: num2 = 13 .
The number is converted to a string represented in binary, base 2.
The number is converted to a string represented in octal, base 8.
number, when this calculation is attempted (see Figure 9.36).