NAME
math.ops - Mathematical Opcodes
DESCRIPTION
Operations that perform basic mathematics. See src/dynoplibs/ for more advanced operations.
When making changes to any ops file,
run make bootstrap-ops to regenerate all generated ops files.
Arithmetic operations
These operations store the results of arithmetic on other registers and constants into their destination register, $1.
- abs(inout INT)
 - abs(inout NUM)
 - abs(invar PMC) Set $1 to its absolute value.
 - abs(out INT, in INT)
 - abs(out NUM, in NUM)
 - abs(out PMC, invar PMC) Set $1 to absolute value of $2.
 - add(inout INT, in INT)
 - add(inout NUM, in NUM)
 - add(invar PMC, invar PMC)
 - add(invar PMC, in INT)
 - add(invar PMC, in NUM) Increase $1 by the amount in $2.
 - add(out INT, in INT, in INT)
 - add(out NUM, in NUM, in NUM)
 - add(invar PMC, invar PMC, invar PMC)
 - add(invar PMC, invar PMC, in INT)
 - add(invar PMC, invar PMC, in NUM) Set $1 to the sum of $2 and $3.
 - dec(inout INT)
 - dec(inout NUM)
 - dec(invar PMC) Decrease $1 by one.
 - div(inout INT, in INT)
 - div(inout NUM, in NUM)
 - div(invar PMC, invar PMC)
 - div(invar PMC, in INT)
 - div(invar PMC, in NUM) Divide $1 by $2.
 - div(out INT, in INT, in INT)
 - div(out NUM, in NUM, in NUM)
 - div(invar PMC, invar PMC, invar PMC)
 - div(invar PMC, invar PMC, in INT)
 - div(invar PMC, invar PMC, in NUM) Set $1 to the quotient of $2 divided by $3. In the case of INTVAL division, the result is truncated (NOT rounded or floored). If the denominator is zero, a 'Divide by zero' exception is thrown.
 - fdiv(inout INT, in INT)
 - fdiv(inout NUM, in NUM)
 - fdiv(invar PMC, invar PMC)
 - fdiv(invar PMC, in INT)
 - fdiv(invar PMC, in NUM) Floor divide $1 by $2.
 - fdiv(out INT, in INT, in INT)
 - fdiv(out NUM, in NUM, in NUM)
 - fdiv(invar PMC, invar PMC, invar PMC)
 - fdiv(invar PMC, invar PMC, in INT)
 - fdiv(invar PMC, invar PMC, in NUM) Set $1 to the quotient of $2 divided by $3. The result is the floor() of the division i.e. the next whole integer towards -inf. If the denominator is zero, a 'Divide by zero' exception is thrown.
 - ceil(inout NUM) Set $1 to the smallest integral value greater than or equal to $1.
 - ceil(out INT, in NUM)
 - ceil(out NUM, in NUM) Set $1 to the smallest integral value greater than or equal to $2.
 - floor(inout NUM) Set $1 to the largest integral value less than or equal to $1.
 - floor(out INT, in NUM)
 - floor(out NUM, in NUM) Set $1 to the largest integral value less than or equal to $2.
 - inc(inout INT)
 - inc(inout NUM)
 - inc(invar PMC) Increase $1 by one.
 - mod(out INT, in INT, in INT)
 - mod(out NUM, in NUM, in NUM)
 - mod(invar PMC, invar PMC, invar PMC)
 - mod(invar PMC, invar PMC, in INT)
 - mod(invar PMC, invar PMC, in NUM) Sets $1 to the modulus of $2 and $3.
 - mod(inout INT, in INT)
 - mod(inout NUM, in NUM)
 - mod(invar PMC, invar PMC)
 - mod(invar PMC, in INT)
 - mod(invar PMC, in NUM) Sets $1 to the modulus of $1 and $2.NOTE: This "corrected mod" algorithm is based on the C code on page 70 of [1]. Assuming correct behavior of the built-in mod operator (%) with positive arguments, this algorithm implements a mathematically convenient version of mod, defined thus:
 - mul(inout INT, in INT)
 - mul(inout NUM, in NUM)
 - mul(invar PMC, invar PMC)
 - mul(invar PMC, in INT)
 - mul(invar PMC, in NUM) Set $1 to the product of $1 and $2.
 - mul(out INT, in INT, in INT)
 - mul(out NUM, in NUM, in NUM)
 - mul(invar PMC, invar PMC, invar PMC)
 - mul(invar PMC, invar PMC, in INT)
 - mul(invar PMC, invar PMC, in NUM) Set $1 to the product of $2 and $3.
 - neg(inout INT)
 - neg(inout NUM)
 - neg(invar PMC) Set $1 to its negative.
 - neg(out INT, in INT)
 - neg(out NUM, in NUM)
 - neg(out PMC, invar PMC) Set $1 to the negative of $2.
 - sub(inout INT, in INT)
 - sub(inout NUM, in NUM)
 - sub(invar PMC, invar PMC)
 - sub(invar PMC, in INT)
 - sub(invar PMC, in NUM) Decrease $1 by the amount in $2.
 - sub(out INT, in INT, in INT)
 - sub(out NUM, in NUM, in NUM)
 - sub(invar PMC, invar PMC, invar PMC)
 - sub(invar PMC, invar PMC, in INT)
 - sub(invar PMC, invar PMC, in NUM) Set $1 to $2 minus $3.
 - sqrt(out NUM, in NUM) Set $1 to the square root of $2.
 
x mod y = x - y * floor(x / y)For more information on this definition of mod, see section 3.4 of [2], pages 81-85.References:
  [1] Donald E. Knuth, *MMIXware: A RISC Computer for the Third
      Millennium* Springer, 1999.
  [2] Ronald L. Graham, Donald E. Knuth and Oren Patashnik, *Concrete
      Mathematics*, Second Edition. Addison-Wesley, 1994.
COPYRIGHT
Copyright (C) 2001-2009, Parrot Foundation.
LICENSE
This program is free software. It is subject to the same license as the Parrot interpreter itself.