biginteger and bigfloat vectors support many of the standard mathematical
operations. The base R documentation can be found by searching for the
individual functions (e.g. mean()
).
The returned value depends on the individual function. We recommend reading the base R documentation for a specific function to understand the expected result.
Other bignum operations:
bignum-arith
,
bignum-compare
,
bignum-special
# summary
x <- bigfloat(1:5)
sum(x)
#> <bigfloat[1]>
#> [1] 15
prod(x)
#> <bigfloat[1]>
#> [1] 120
max(x)
#> <bigfloat[1]>
#> [1] 5
min(x)
#> <bigfloat[1]>
#> [1] 1
range(x)
#> <bigfloat[2]>
#> [1] 1 5
mean(x)
#> <bigfloat[1]>
#> [1] 3
# cumulative
x <- bigfloat(1:5)
cumsum(x)
#> <bigfloat[5]>
#> [1] 1 3 6 10 15
cumprod(x)
#> <bigfloat[5]>
#> [1] 1 2 6 24 120
cummax(x)
#> <bigfloat[5]>
#> [1] 1 2 3 4 5
cummin(x)
#> <bigfloat[5]>
#> [1] 1 1 1 1 1
# rounding
x <- bigfloat(1.5)
floor(x)
#> <bigfloat[1]>
#> [1] 1
ceiling(x)
#> <bigfloat[1]>
#> [1] 2
trunc(x)
#> <bigfloat[1]>
#> [1] 1
# miscellaneous
x <- bigfloat(2)
abs(x)
#> <bigfloat[1]>
#> [1] 2
sign(x)
#> <bigfloat[1]>
#> [1] 1
sqrt(x)
#> <bigfloat[1]>
#> [1] 1.414214
# logarithms and exponentials
x <- bigfloat(2)
log(x)
#> <bigfloat[1]>
#> [1] 0.6931472
log10(x)
#> <bigfloat[1]>
#> [1] 0.3010300
log2(x)
#> <bigfloat[1]>
#> [1] 1
log1p(x)
#> <bigfloat[1]>
#> [1] 1.098612
exp(x)
#> <bigfloat[1]>
#> [1] 7.389056
expm1(x)
#> <bigfloat[1]>
#> [1] 6.389056
# trigonometric
x <- bigfloat(0.25)
cos(x)
#> <bigfloat[1]>
#> [1] 0.9689124
sin(x)
#> <bigfloat[1]>
#> [1] 0.2474040
tan(x)
#> <bigfloat[1]>
#> [1] 0.2553419
acos(x)
#> <bigfloat[1]>
#> [1] 1.318116
asin(x)
#> <bigfloat[1]>
#> [1] 0.2526803
atan(x)
#> <bigfloat[1]>
#> [1] 0.2449787
cospi(x)
#> <bigfloat[1]>
#> [1] 0.7071068
sinpi(x)
#> <bigfloat[1]>
#> [1] 0.7071068
tanpi(x)
#> <bigfloat[1]>
#> [1] 1
# hyperbolic
x <- bigfloat(0.25)
cosh(x)
#> <bigfloat[1]>
#> [1] 1.031413
sinh(x)
#> <bigfloat[1]>
#> [1] 0.2526123
tanh(x)
#> <bigfloat[1]>
#> [1] 0.2449187
acosh(bigfloat(2))
#> <bigfloat[1]>
#> [1] 1.316958
asinh(x)
#> <bigfloat[1]>
#> [1] 0.2474665
atanh(x)
#> <bigfloat[1]>
#> [1] 0.2554128
# special functions
x <- bigfloat(2.5)
gamma(x)
#> <bigfloat[1]>
#> [1] 1.329340
lgamma(x)
#> <bigfloat[1]>
#> [1] 0.2846829
digamma(x)
#> <bigfloat[1]>
#> [1] 0.7031566
trigamma(x)
#> <bigfloat[1]>
#> [1] 0.4903578
factorial(x)
#> <bigfloat[1]>
#> [1] 3.323351
lfactorial(x)
#> <bigfloat[1]>
#> [1] 1.200974