Bigzs are integers of infinite, but given length (means: only
restricted by the host memory). Basic arithmetic operations can be performed
on bigzs as addition, subtraction, multiplication, division, modulation
(remainder of division), power, multiplicative inverse, calculating of the
greatest common divisor, test whether the integer is prime and other things
that comes in need when performing standard cryptographic operations. For a review of basic arithmetics, see "add.bigz"
.
The most important logical operators are supported, such as "=="
, "!="
,
"<"< code="">, "<="< code="">, ">"
, and ">="
.="<>
"<>
Objects of class "bigz"
may have an attribute mod
which specifies a modulus that is applied after each arithmetic operation.
If the result is going to have a modulus,
result = mod.bigz(result, modulus)
is called after performing the arithmetic operation and the result will have the
attribute mod
set accordingly.
Powers of bigzs can only be performed, if either a modulus is going to
be applied to the result bigz or if the exponent fits into an integer
value. So if you want to calculate a power in a finite group, don't use
a ^ b %% c
, but use as.bigz(a,c) ^ b
, instead.
The following rules for the result's modulus apply when performing
arithmetic operations on bigzs:
- If none of the operand has a modulus set, the result will not have a modulus.
- If both operands have a different modulus, the result will not have a
modulus, except in case of
"mod.bigz"
, where the second operands
value is used. - If only one of the operands has a modulus or both have a common (the
same), it is set and applied to the result, except in case of mod.bigz,
where the second operands value is used.