lang/postscript/ PostscriptMathematicalOperations1
Taken from: http://www.linuxfocus.org/English/July1999/article80.html
add: This command needs two numerical parameters whose values enter the addition operation. If these values are, say m and n, then the command is given as m n add. When this is done, first m then n is pushed into the operand stack. The action of the add operator onto these two topmost elements of the operand stack is the final stage. It creates a new element with the value which is equal to the sum of m and n. When the operation is completed m and n is not held in the operand stack. Instead, the result becomes the topmost element of the operand stack.
div: This command needs two numerical parameters whose values enter the division operation. If these values are, say m and n, then the command is given as m n div. The operation mechanism is same with the one for add. Division operation is at the floating point arithmetic level. After the operation is done only the result remains in the operand stack as a new element. m and n is not maintained.
idiv: This command needs two numerical parameters whose values enter the integer division operation. If these values are, say m and n, then the command is given as m n idiv. Everything is the same with div except the division level. It is an integer arithmetic division operation. If the parameters are not integers it works too.
mod: This command needs two integer parameters. It evaluates the remainder of the division of the first parameter by the second. If any one of the parameters is not an integer then it fails to work. The result is the only maintained value in the operand stack after the operation takes place.
mul: Same as add, div. It is a binary operator which needs two numerical values. The result is the multiplication of the parameters and is maintained as a new element in the operand stack.
sub: Same as add, div, mul. The only difference is the operation type. It subtracts the value of the second parameter from the value of the first. Parameters and the result are numerical values and the result is maintained in the operand stack after the operation is complete.
exp: This is a binary mathematical operator. It needs two parameters. The first is the base and the second is the exponent. It raises the value of the base to the power whose value is the exponent. The parameters must be within the limitations for the exponentiation operation. The result which is a floating point number that is maintained as a new element in the operand stack.
atan: This is another binary mathematical operator for the evaluation of an angle. The angle is given in degrees between 0 and 360. It needs two parameters. The ratio of the first parameter to the second equals the tangent of the angle to be evaluated. Any one of the parameters may be zero but both cannot be given zero values. The signs of the parameters determine the quadrant where the result will lie. The positive values in the first parameter corresponds to positive y plane. Whereas, the positive values in the second parameter mean positive x plane.
abs: This is a unary mathematical operator. It needs only one parameter whose absolute value is the result. Similarly as above, the result is maintained as a new element in the operand stack.
neg: This changes the sign of its only argument. It is a unary arithmetic operator.
ceiling: This is a unary operator which evaluates the integer value closest to its argument from above.
floor: This is a unary operator which evaluates the integer value closest to its argument from below.
round: This is a unary operator which evaluates the integer value closest to its argument.
truncate: This is a unary operator which removes the fractional part of its argument.
sqrt: This is a unary operator which evaluates the square root of its argument.
cos: This is a unary operator which evaluates the cosine of its argument. The argument is assumed to be given in degrees.
sin: This is a unary operator which evaluates the sine of its argument. The argument is assumed to be given in degrees.
ln: This is a unary operator which evaluates the natural logarithm of its argument.
log: This is a unary operator which evaluates the base-10 logarithm of its argument. Page PostscriptMathematicalOperations1 does not exist yet.