Name

Number.MAX_VALUE Property — the largest representable positive number in ActionScript

Availability

Flash 5

Synopsis

Number.MAX_VALUE

Access

Read-only

Description

The MAX_VALUE property stores the largest representable positive number in ActionScript (1.7976931348623157e+308). It is convenient when you’d like to start with a very large value, as shown in the following example. Any number greater than MAX_VALUE can’t be represented by ActionScript and is therefore considered to be POSITIVE_INFINITY.

Example

Here we are looking for a minimum value in an array. We initialize the minVal variable to MAX_VALUE, knowing that any subsequent value will be less than it:

var myArray = [-10, 12, 99]
var minVal = Number.MAX_VALUE
for (thisValue in myArray) {
  if (myArray[thisValue] < minVal) {
    minVal = myArray[thisValue];
  }
}
trace ("The minimum value is " + minVal);

See Also

Number.MIN_VALUE; Number.POSITIVE_INFINITY; Section 4.3.3 in Chapter 4

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.