User Guide : Scripting : Script Statements : Option Math Statements
 
Share this page             
Option Math Statements
Option math statements specify how the map performs arithmetic operations. These statements are transformation-level settings; once used, the statement remains in effect throughout all expressions in a transformation, unless another statement changes the setting.
The available option math statements include:
Option Math Fast Statement
Option Math Precise Statement
Option Math Strict Statement
Calculations are either done with floating point or decimal values.
A number can be specified with &D in front of it (analogous to '&H' to specify a hex number). The &D specifies the number should be treated as a decimal number, and can have up to 30 digits before the decimal point and up to eight after the decimal point.
Example
x=1234567890.123456789

FileWrite("Without using the &D prefix: " & x*1234567890.12)
If you do not use the &D prefix, a FileWrite writes the following result:
1524157875319615700
Whereas if you enter the following:
x=&D1234567890.123456789

FileWrite("Using the &D prefix: " & x*&D1234567890.12)
If you use the &D prefix, a FileWrite writes the following result:
1542157875319616034.31672002468
Option Math Fast Statement
 
Description
If both operands are longs, the map performs long (32-bit integer) arithmetic. If either operand is a floating point number, the arithmetic is performed as floating point.
Syntax
Option Math Fast
Remarks
Math is performed using floating point values, since they are much faster than decimal values.
This statement is a context-setting at the transformation level. If Option Math Fast is used once, the setting remains in effect for all expressions in a transformation, unless another statement changes the setting.
Option Math Precise Statement
 
Description
Perform decimal arithmetic
Syntax
Option Math Precise
Remarks
This statement is used to force decimal arithmetic, unless one of the operands is a floating point number. In this case, the math is done as floating point. If the result overflows or underflows, it converts both numbers to floating point and tries again.
This statement is a context-setting at the transformation level. If Option Math Precise is used once, the setting remains in effect for all expressions in a transformation, unless another statement changes the setting.
Option Math Strict Statement
 
Description
Perform decimal arithmetic
Syntax
Option Math Strict
Remarks
This statement is similar to Option Math Precise, however, if an overflow or underflow occurs, a run-time error is generated (instead of transformation of the numbers to floating point).
This statement is a context-setting at the transformation level. If Option Math Strict is used once, the setting remains in effect for all expressions in a transformation, unless another statement changes the setting.