Any of the above forms of numerical expression can be used where Pop-11 requires an expression, e.g. to assign values to variables, or to give arguments to procedures requiring numerical arguments. Mathematical procedures provided by Pop-11 are listed below, including the standard arithmetical operators (+, -, *, /), trigonometrical functions (sin, cos, tan) and others.
Starting from expressions denoting numbers we can create more complicated expressions denoting numbers. E.g.
33 + 44 denotes the number 7 sqrt(9) denotes the number 3.0 max(4, 77) denotes the number 77.Arithmetic expressions can be embedded in others. For example the expression
tan(23 + 22)contains sub-expressions 23, 22, and 23 + 22.
Finally
max(min(66, 33), min(999, 9))denotes the number 33, as does this:
max( min(66-5, 33), min(999, 9+9) ) => ** 33Exercise: How many different expressions does the last example contain?
Pop-11 will read in binary numbers if they are preceded by `2:'
2:111 => ** 7Similarly octal numbers may be preceded by `8:'
8:111 => ** 73This sort of prefix can be used for non-integer numbers too:
8:11.11 => ** 9.140625 10:55.55 => ** 55.55The integer base used for reading in non-decimal numbers must be in the range 2-36. If the base is greater than 10, the letters A-Z (uppercase only) can be used in the number to represent digit values from 10 to 35, e.g. 16:1FFA represents 8186 as a hexadecimal number.
Note: the same internal representation is used, no matter how the number is read in. So how the number prints out is not affected. E.g.
2:111, 7 => ** 7 7 2:111 == 7 => ** <true>
How numbers are printed is controlled using pop_pr_radix, which defaults to 10. By making it 16 numbers can be printed in hexadecimal, for instance:
16 -> pop_pr_radix; 16 => ** 10 15 => ** FYou can define a procedure to print numbers in binary form thus:
define pr_binary(num); dlocal pop_pr_radix = 2; pr(num) enddefine; vars x; for x from 1 to 15 do pr_binary(x); pr(space) endfor; 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111
The printing of decimal (floating point) numbers is also controlled by pop_pr_radix.
16 -> pop_pr_radix; 15.55 => ** F.8CCCCDCompare
pr_binary(15.55); 1111.100011The number of decimal places shown is controlled by pop_pr_places, which defaults to 6.
10 -> pop_pr_radix; sqrt(2) => ** 1.41421 2 -> pop_pr_places; sqrt(2) => ** 1.41 6 -> pop_pr_places; sqrt(2) => ** 1.41421A value of 0 causes decimal numbers to be printed as integers.
If pop_pr_exponent is made true (it defaults to false) then exponent form is used for printing decimals and ddecimals:
true -> pop_pr_exponent; sqrt(20000) => ** 1.41421e+2 false -> pop_pr_exponent; sqrt(20000) => ** 141.421As explained above, the exponent notation can also be used for reading in decimals:
1.41421e+2 => ** 141.421