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.
| Function | Module |
|---|---|
add, subtract | decimo.bigfloat.arithmetics |
multiply, divide | decimo.bigfloat.arithmetics |
sqrt | decimo.bigfloat.exponential |
root, cbrt | decimo.bigfloat.exponential |
hypot | decimo.bigfloat.exponential |
exp, ln | decimo.bigfloat.exponential |
exp2, exp10 | decimo.bigfloat.exponential |
log2, log10, log | decimo.bigfloat.exponential |
expm1, log1p | decimo.bigfloat.exponential |
power | decimo.bigfloat.power |
sin, cos, tan | decimo.bigfloat.trigonometric |
cot, csc, sec | decimo.bigfloat.trigonometric |
arcsin, arccos, arctan | decimo.bigfloat.trigonometric |
arctan2 | decimo.bigfloat.trigonometric |
sinh, cosh, tanh | decimo.bigfloat.hyperbolic |
arcsinh, arccosh, arctanh | decimo.bigfloat.hyperbolic |
pi, ln2, ln10, e | decimo.bigfloat.constants |
fma, remainder, fmod | decimo.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.
| Function | Description |
|---|---|
next_plus, next_minus | The neighbour at a given precision |
next_toward | The neighbour in another value’s direction |
logb | The leading bit’s position, as a BigInt |
scaleb | Times a power of two, exactly |
copy_sign, copy_abs, copy_negate | The sign, never raising |
number_class | The specification’s name for the value |
is_integer | Whether there is a fractional part |
truncate, floor, ceil | The three named roundings to a whole number |
round_to_integer | The same in any of the seven modes |
| Operator / Method | Description |
|---|---|
a + b, a - b | At the wider precision, half to even |
a * b, a / b, a ** b | The 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 rest | The literal converts, then as a + b |
a += b, a -= b, a *= b, a /= b | As a + b and the rest |
a **= b | As a ** b |
-a, abs(a) | Exact |
a == b, a < b, and the rest | False 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 / Method | Accepts | Raises? | Description |
|---|---|---|---|
a + b | BInt, Int | No | Addition |
a - b | BInt, Int | No | Subtraction |
a * b | BInt, Int | No | Multiplication |
a / b | BInt, Int | Yes | Truncating division |
a // b | BInt, Int | Yes | Floor division |
a % b | BInt, Int | Yes | Floor modulo |
a ** b | BInt, Int | Yes | Power |
a << n | Int | No | Left shift |
a >> n | Int | No | Right shift |
a & b | BInt, Int | No | Bitwise AND |
a | b | BInt, Int | No | Bitwise OR |
a ^ b | BInt, Int | No | Bitwise XOR |
~a | — | No | Bitwise NOT |
-a | — | No | Negation |
abs(a) | — | No | Absolute value |
a.sqrt() | — | Yes | Integer square root |
a.gcd(b) | BInt | No | GCD |
a.lcm(b) | BInt | Yes | LCM |
a.extended_gcd(b) | BInt | Yes | Extended GCD |
a.mod_pow(e, m) | BInt/Int, BInt | Yes | Modular exponentiation |
a.mod_inverse(m) | BInt | Yes | Modular inverse |
Decimal — Mathematical Functions
| Function | Signature | Default | Description |
|---|---|---|---|
sqrt | x.sqrt(precision=28) | 28 | Square root |
cbrt | x.cbrt(precision=28) | 28 | Cube root |
root | x.root(n, precision=28) | 28 | Nth root |
power | x.power(exponent=e, precision=28) | 28 | Exponentiation |
exp | x.exp(precision=28) | 28 | e^x |
ln | x.ln(precision=28) | 28 | Natural logarithm |
log | x.log(base=b, precision=28) | 28 | Logarithm (any base) |
log10 | x.log10(precision=28) | 28 | Base-10 logarithm |
sin | x.sin(precision=28) | 28 | Sine (radians) |
cos | x.cos(precision=28) | 28 | Cosine (radians) |
tan | x.tan(precision=28) | 28 | Tangent (radians) |
cot | x.cot(precision=28) | 28 | Cotangent (radians) |
csc | x.csc(precision=28) | 28 | Cosecant (radians) |
sec | x.sec(precision=28) | 28 | Secant (radians) |
arctan | x.arctan(precision=28) | 28 | Arctangent (radians) |
pi | Decimal.pi(precision) | — | Compute π |
e | Decimal.e(precision) | — | Compute e |
Built from decimo main. This page in the manual.