Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix C — Complete API Tables

BigFloat — All Functions

Every one of these takes a precision in bits and a rounding mode, and returns the float of that precision nearest the true value.

FunctionModule
add, subtractdecimo.bigfloat.arithmetics
multiply, dividedecimo.bigfloat.arithmetics
sqrtdecimo.bigfloat.exponential
root, cbrtdecimo.bigfloat.exponential
hypotdecimo.bigfloat.exponential
exp, lndecimo.bigfloat.exponential
exp2, exp10decimo.bigfloat.exponential
log2, log10, logdecimo.bigfloat.exponential
expm1, log1pdecimo.bigfloat.exponential
powerdecimo.bigfloat.power
sin, cos, tandecimo.bigfloat.trigonometric
cot, csc, secdecimo.bigfloat.trigonometric
arcsin, arccos, arctandecimo.bigfloat.trigonometric
arctan2decimo.bigfloat.trigonometric
sinh, cosh, tanhdecimo.bigfloat.hyperbolic
arcsinh, arccosh, arctanhdecimo.bigfloat.hyperbolic
pi, ln2, ln10, edecimo.bigfloat.constants
fma, remainder, fmoddecimo.bigfloat.ieee

log takes the base as its second argument, before the precision. Every other one takes the argument, the precision and the mode.

cot and csc have a pole at zero and return an infinity of the zero’s sign, the way a float does; BigDecimal raises there instead, having no infinity to return. No other pole of the six is a binary float, so every other argument has an answer, however large it is.

These take no rounding mode, or no precision, because their answers are exact or carry the argument’s own precision. All of them are in decimo.bigfloat.ieee, and all of them are methods as well.

FunctionDescription
next_plus, next_minusThe neighbour at a given precision
next_towardThe neighbour in another value’s direction
logbThe leading bit’s position, as a BigInt
scalebTimes a power of two, exactly
copy_sign, copy_abs, copy_negateThe sign, never raising
number_classThe specification’s name for the value
is_integerWhether there is a fractional part
truncate, floor, ceilThe three named roundings to a whole number
round_to_integerThe same in any of the seven modes
Operator / MethodDescription
a + b, a - bAt the wider precision, half to even
a * b, a / b, a ** bThe same
BigFloat(text), BigFloat(x)At fifty-three bits; a Float64 is exact
BigFloat(n)Exact, at fifty-three bits or more
BigFloat(v, p, mode)At p bits, in mode
1 + a, 2 * a, 2 ** a, and the restThe literal converts, then as a + b
a += b, a -= b, a *= b, a /= bAs a + b and the rest
a **= bAs a ** b
-a, abs(a)Exact
a == b, a < b, and the restFalse for a NaN, both zeros equal
a.sqrt()At a’s own precision, half to even
a.fma(b, c, p)a * b + c, the product formed exactly
a.remainder(b, p), a.fmod(b, p)The two remainders
a.next_plus(p), a.next_minus(p)The neighbours
a.logb(), a.scaleb(n)The exponent, read and written
a.truncate(), a.floor(), a.ceil()Rounded to a whole number
a.round_to_integer(mode)The same in any mode
a.number_class(), a.is_integer()What kind of value it is
a.exp(), a.ln()The same
a.exp2(), a.exp10()The same; a whole exponent is exact
a.log2(), a.log10()The same; a whole power of the base is exact
a.log(base=b)At the wider precision, half to even
a.expm1(), a.log1p()The same; these keep a small argument
a.sin(), a.cos(), a.tan()At a’s own precision, half to even
a.cot(), a.csc(), a.sec()The same
a.arcsin(), a.arccos(), a.arctan()The same
a.sinh(), a.cosh(), a.tanh()The same
a.arcsinh(), a.arccosh(), a.arctanh()The same
a.exp(p), a.exp(p, mode)sqrt, and exp to arctanh, at p bits
BigFloat.zero(), BigFloat.one()At fifty-three bits
a.to_bigdecimal()The exact decimal expansion
a.to_bigdecimal_rounded(n)n significant digits
a.to_float64()The nearest double
a.internal_representation()The significand, exponent and precision

BigInt — All Operators

Operator / MethodAcceptsRaises?Description
a + bBInt, IntNoAddition
a - bBInt, IntNoSubtraction
a * bBInt, IntNoMultiplication
a / bBInt, IntYesTruncating division
a // bBInt, IntYesFloor division
a % bBInt, IntYesFloor modulo
a ** bBInt, IntYesPower
a << nIntNoLeft shift
a >> nIntNoRight shift
a & bBInt, IntNoBitwise AND
a | bBInt, IntNoBitwise OR
a ^ bBInt, IntNoBitwise XOR
~a—NoBitwise NOT
-a—NoNegation
abs(a)—NoAbsolute value
a.sqrt()—YesInteger square root
a.gcd(b)BIntNoGCD
a.lcm(b)BIntYesLCM
a.extended_gcd(b)BIntYesExtended GCD
a.mod_pow(e, m)BInt/Int, BIntYesModular exponentiation
a.mod_inverse(m)BIntYesModular inverse

Decimal — Mathematical Functions

FunctionSignatureDefaultDescription
sqrtx.sqrt(precision=28)28Square root
cbrtx.cbrt(precision=28)28Cube root
rootx.root(n, precision=28)28Nth root
powerx.power(exponent=e, precision=28)28Exponentiation
expx.exp(precision=28)28e^x
lnx.ln(precision=28)28Natural logarithm
logx.log(base=b, precision=28)28Logarithm (any base)
log10x.log10(precision=28)28Base-10 logarithm
sinx.sin(precision=28)28Sine (radians)
cosx.cos(precision=28)28Cosine (radians)
tanx.tan(precision=28)28Tangent (radians)
cotx.cot(precision=28)28Cotangent (radians)
cscx.csc(precision=28)28Cosecant (radians)
secx.sec(precision=28)28Secant (radians)
arctanx.arctan(precision=28)28Arctangent (radians)
piDecimal.pi(precision)—Compute π
eDecimal.e(precision)—Compute e

Built from decimo main. This page in the manual.