Example 10.1. Numbers
12 /* a whole number */ "-76" /* a signed whole number */ 12.76 /* decimal places */ " + 0.003 " /* blanks around the sign and so forth */ 17. /* same as 17 */ .5 /* same as 0.5 */ 4E9 /* exponential notation */ 0.73e-7 /* exponential notation */
>>-+------------+--+----------------------+--+-digits--------+----------> +-whitespace-+ +-sign--+------------+-+ +-digits.digits-+ +-whitespace-+ +-.digits-------+ +-digits.-------+ >--+------------+-------------------------------------------------->< +-whitespace-+
+
or -
.
0
-9
.
+
), subtraction (-
), multiplication (*
), power (**
), division (/
), prefix plus (+
), and prefix minus (-
). In addition, it includes integer divide (%
), which divides and returns the integer part, and remainder (//
), which divides and returns the remainder. For examples of the arithmetic operators, see Section 10.2.4, “Operator Examples”.
9
, but can be overridden on a source-file basis with the ::OPTIONS directive (Section 3.5, “::OPTIONS”). The default setting can be altered with the NUMERIC DIGITS instruction. Thus, with NUMERIC DIGITS 9, if a result requires more than 9 digits, it is rounded to 9 digits. For example, the division of 2 by 3 results in 0.666666667.
0
.
Example 10.3. Arithmetic
1e6 * 1e6 -> 1E+12 /* not 1000000000000 */ 1 / 3E10 -> 3.33333333E-11 /* not 0.0000000000333333333 */
>>-NUMERIC DIGITS--+------------+--;--------------------------->< +-expression-+
9
. The default may be overridden on a source-file basis using the ::OPTIONS directive (Section 3.5, “::OPTIONS”).