Basic arithmetic and logical operators for vli (Very Large Integers) objects.
# S3 method for vli
+(x, y)# S3 method for vli
-(x, y)
# S3 method for vli
*(x, y)
# S3 method for vli
/(x, y)
# S3 method for vli
%%(x, y)
# S3 method for vli
abs(x)
# S3 method for vli
^(x, y)
# S3 method for vli
>(x, y)
# S3 method for vli
<(x, y)
# S3 method for vli
>=(x, y)
# S3 method for vli
<=(x, y)
# S3 method for vli
==(x, y)
# S3 method for vli
!=(x, y)
objects of class vli with the arithmetic operators; booleans with the logical operators
object of class vli or 32 bits integer
object of class vli or 32 bits integer
Javier Leiva Cuadrado
As in the creation of vli objects (through the function as.vli
), punctuation signs will be ignored (see the last example).
The algorithm implemented for the operator "*
" computes the product with a trivial method when imput numbers have less than 40 digits and with the Karatsuba algorithm for fast multiplications when they are larger.
x <- as.vli("712376544526091241")
x ^ 61
x / as.vli("4225234")
x > -x
x <= 10000000
13.2415 - as.vli(132415)
Run the code above in your browser using DataLab