Wilang Documentation1.0.0+4

Arithmetic and numbers#

Rounding and sign#

floor rounds toward minus infinity, ceil toward plus infinity, fix toward zero, and round to the nearest value. Negative inputs make the difference obvious.

Example
floor(3.2)
floor(3.8)
floor(-4.2)
Example
ceil(-3.8)
fix(-3.8)
round(pi,3)
abs(-5)
sign(-5)

Powers, roots, and logarithms#

Use ^, sqrt, cbrt, nthRoot, exp, log, log2, and log10. For log, the base goes last: log(value, base). Near zero, prefer log1p and expm1, which keep precision. See Complex numbers for complex roots.

Example
sqrt(25)
cbrt(-8)
nthRoot(16,4)
log(1000,10)

Exact and large values#

By default, Number uses floating-point arithmetic. Change the note default with Numeric Type in Math settings, or pick a type per expression:

Example
fraction(1,3) + fraction(1,6)
bignumber("0.1") + bignumber("0.2")
bigint("12345678901234567890")

A fraction is an exact rational. BigNumber keeps decimals at higher precision. BigInt holds integers only, so it does not suit ordinary fractional work. Build large precise values from strings, otherwise Number rounds them first.

Integers and special functions#

The reference also covers factorial, gamma and log-gamma, gcd and lcm, modular inverse, extended GCD, primality, combinatorics, Bernoulli numbers, Catalan, Bell and Stirling numbers, the error function, and zeta.

Example
factorial(5)
gcd(12,18)
lcm(12,18)
invmod(3,11)
isPrime(7)

Bits and predicates#

bitAnd, bitOr, bitXor, bitNot, leftShift, rightArithShift, and rightLogShift work on integer bits. isFinite, isNaN, isInteger, isPositive, and isZero test values. Check the individual overloads before using BigInt.

All arithmetic functions · Statistics