• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5. Operators > Arithmetic Operators

5.3. Arithmetic Operators

The arithmetic operators perform mathematical operations on numeric operands. If you use nonnumeric operands with most of the arithmetic operators, ActionScript attempts to convert the foreign data to a number. For example, false - true evaluates to -1, because false converts to the numeric value 0 and true converts to 1. Similarly, the expression "3" * "5" results in the number 15, because the strings "3" and "5" are converted to the numbers 3 and 5 before the multiplication is performed. The + operator, however, presents a special case: when used with at least one string operand, it performs string concatenation, not mathematical addition.

If an attempt to convert a nonnumeric operand to a number fails, the operand is set to the special numeric value NaN. This results in the entire operation yielding NaN. Refer to Table 3-1 for details on numeric conversion.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint