Go to the first, previous, next, last section, table of contents.


Arithmetic

`+'
Pops two values off the stack, adds them, and pushes the result. The precision of the result is determined only by the values of the arguments, and is enough to be exact.
`-'
Pops two values, subtracts the first one popped from the second one popped, and pushes the result.
`*'
Pops two values, multiplies them, and pushes the result. The number of fraction digits in the result is controlled by the current precision value (see below) and does not depend on the values being multiplied.
`/'
Pops two values, divides the second one popped from the first one popped, and pushes the result. The number of fraction digits is specified by the precision value.
`%'
Pops two values, computes the remainder of the division that the `/' command would do, and pushes that. The division is done with as many fraction digits as the precision value specifies, and the remainder is also computed with that many fraction digits.
`~'
Pops two values, divides the second one popped from the first one popped. The quotient is pushed first, and the remainder is pushed next. The number of fraction digits used in the division is specified by the precision value. (The sequence SdSn lnld/ LnLd% could also accomplish this function, with slightly different error checking.) (This command is a GNU extension.)
`^'
Pops two values and exponentiates, using the first value popped as the exponent and the second popped as the base. The fraction part of the exponent is ignored. The precision value specifies the number of fraction digits in the result.
`|'
Pops three values and computes a modular exponentiation. The first value popped is used as the reduction modulus; this value must be a non-zero number, and the result may not be accurate if the modulus is not an integer. The second popped is used as the exponent; this value must be a non-negative number, and any fractional part of this exponent will be ignored. The third value popped is the base which gets exponentiated. The precision value specifies the number of fraction digits in the result. For small numbers this is like the sequence Sm lble^ Lm%, but, unlike ^, this command will work with arbritrarily large exponents.
`v'
Pops one value, computes its square root, and pushes that. The precision value specifies the number of fraction digits in the result.

Most arithmetic operations are affected by the precision value, which you can set with the `k' command. The default precision value is zero, which means that all arithmetic except for addition and subtraction produces integer results.

The remainder operation (`%') requires some explanation: applied to arguments `a' and `b' it produces `a - (b * (a / b))', where `a / b' is computed in the current precision.


Go to the first, previous, next, last section, table of contents.