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 ...

Get Lingo in a Nutshell 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.