
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Numeric Literals
|
79
Integer Literals
Integer literals, such as 1, 2, 3, 99, and -200, must follow these rules:
• Integers may not contain a decimal point or fractional value.
• Integers must not exceed the minimum or maximum legal numeric values of
ActionScript. See the
MIN_VALUE and MAX_VALUE properties of the Number object
in the Language Reference for a discussion of legal values.
• Base-10 integer numbers must not start with a leading zero (e.g., these are not
valid base-10 integers: 002, 000023, and 05).
Not all integer values are base-10 (i.e., decimal) integers. ActionScript also supports
base-8 (octal) and base-16 (hexadecimal) numeric literals. For a primer on decimal,
octal, and hexadecimal numbers, see:
http://www.moock.org/asdg/technotes/basePrimer/
We use a leading zero to indicate an octal number. For example, to represent the
octal number 723 in ActionScript, we use:
0723 // 467 in decimal (7*64 + 2*8 + 3*1)
To indicate a hexadecimal (hex for short) literal integer, we put 0x (or 0X) in front of
the number, such as:
0x723 // 1827 in decimal (7*256 + 2*16 + 3*1)
0xFF // 255 in decimal (15*16 + 15*1)
Hexadecimal numbers are often used to indicate color values, but most simple pro-
grams require only base-10 numbers. Be careful to remove unwanted leading zeros
when converting strings ...