O'Reilly logo

Lingo in a Nutshell by Bruce A. Epstein

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

Number Systems and Formats

Never include commas, dollar signs, or formatting symbols when specifying numbers. Only the digits 0-9 and the characters +, -, and the decimal point are valid numeric symbols (exponential notation also uses the letter “E” or “e”).

Rounding and Precision

The manner in which integers and floats are stored and manipulated by computers limits their maximum range and precision.

Display Precision

Director performs all floating-point calculations to 15 significant digits. Floating-point values are never permanently rounded, but are merely displayed rounded to the number of decimal places specified by the floatPrecision. Refer to "Float Truncation" later in this chapter for tips on avoiding errors due to the quirks of floating-point math.

set the floatPrecision = 4
put pi
-- 3.1416
set the floatPrecision = 15
put pi
-- 3.141592653589790
put 5.12345678901234567
-- 5.123456789012350

Numbers Out of Range

The maximum floating-point number is approximately +/-1.797693135e+308. Larger numbers return INF (on Macintosh) or -INF (under Windows) to indicate infinity.

put 2e+308 -- Number is greater than max float
-- INF
put log (0)
-- INF

Attempting an invalid calculation may return a meaningless value.

put log(-1)
-- NAN               -- Macintosh
put log(-1)
-- 0.0000000000e+0   -- Windows

The maxInteger returns the maximum positive integer (2147483647, which equals 231−1). The minimum integer is −2147483648 (Macintosh) or −2147483647 (Windows). Adding to the maxInteger or subtracting from the ...

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