O'Reilly logo

ActionScript 3.0 Bible by Roger Braunstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Numbers, Math, and Dates

FEATURED CLASSES

  • Number

  • int

  • uint

  • Math

  • Date

Without good support for numbers, there's not much you can program. It should be no surprise, then, that ActionScript 3.0 enables all kinds of numeric activity, from basic arithmetic to date and time handling. With the information in this chapter, you can start making useful, interactive, and aesthetic computations.

Understanding Numeric Types

Using ActionScript, you can create numbers of different types. To understand how to use these, however, you must take a step back and look at the sets of numbers themselves and what they represent. Later, you will review how different kinds of numbers are represented on modern computers. Knowing the implications of these implementation details can help the wary programmer understand which data types are appropriate in which situations, the limitations of the language, and common problems that might arise. If you're familiar with numeric types in other languages, you might want to skip ahead to "Using Numbers in ActionScript."

Sets of Numbers

A number is a number is a number, right? Not so; there are several types of numbers. These types of numbers are defined by the set of values that they can represent.

Most familiar might be the set of natural numbers, or N. This set contains whole numbers starting with zero: {0, 1, 2, 3, ...}. These are the numbers you use to count discrete objects: "I have two parents." "There are four emergency exits on this aircraft." "This piano has ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required