as.bigz(a, mod = NA)
as.character.bigz(a)
as.double.bigz(x,...)is.na.bigz(a)
print.bigz(x,...)
0x
for hexadecimal, 0b
for
binary or without prefix for decimal values.
Any format error results in 0
) 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:
"mod.bigz"
, where the second operands
value is used.
[object Object]
## calculate c = x^e mod n x <- as.bigz("0x123456789abcdef") # my secret message e <- as.bigz(3) # something smelling like a dangerous public RSA exponent n <- as.bigz("0x4378a27...") # probably a product of two primes
# first way to do it right modulus(x) <- n c <- x ^ e
# similar second way (maybe more sensefull if you reuse e) to do it right modulus(e) <- n c <- x ^ e
# third way to do it right c <- x ^ as.bigz(e, n)
# WRONG! (although very beautiful. Maybe ok for small examples) c <- x ^ e