Number Library (Num)
Linked to number types.
Library for manipulating and using numbers, automatically linked to the number types (int, float, & units).
Example Usage
#[main]
fn main() {
assert_eq(Num.abs(-23), 23);
const val = -5;
assert_eq(val.abs(), 5);
}Num.abs(val: int | float) -> int | float
Return the absolute value of the given number.
const v = -2;
assert_eq(v.abs(), 2);Num.acos(val: int | float) -> rad
Arc Cosine function (returns a float with radian units).
Num.acosh(val: int | float) -> float
Inverse hyperbolic Cosine function.
Num.asin(val: int | float) -> rad
Arc Sine function (returns a float with radian units).
Num.asinh(val: int | float) -> float
Inverse hyperbolic Sine function.
Num.at(val: int | float, index: int) -> int
Index into this number (helpful for iteration of single value ranges).
Num.atan(val: int | float) -> rad
Arc Tangent function (returns a float with radian units).
Num.atan2(y: int | float, x: int | float) -> rad
Computes the four quadrant arctangent of self (y) and other (x) in radians.
Num.atanh(val: int | float) -> float
Inverse hyperbolic Tangent function.
Num.bin(val: int) -> str
Returns this number represented as a binary string.
Num.cbrt(val: int | float) -> float
Return the cube root of a number.
Num.ceil(val: int | float) -> int | float
Return the smallest integer greater than or equal to the given value.
Num.cos(val: int | float) -> float
Cosine function.
Num.cosh(val: int | float) -> float
Hyperbolic Cosine function.
Num.exp(val: int | float) -> float
Exponential function (e^(val)).
Num.exp2(val: int | float) -> float
Exponential 2 function (2^(val)).
Num.floor(val: int | float) -> int | float
Return the largest integer less than or equal to the given value.
Num.fract(val: int | float) -> int | float
Return the fractional part of this number.
Num.has_units(val: int | float) -> bool
Returns true if the given number has units.
Num.hex(val: int) -> str
Returns this number represented as a hexidecimal string.
Num.inf(val: int | float) -> bool
Return true if this value is infinity.
Num.is_angle(val: int | float) -> bool
Returns true if the given number has angular units (degrees or radians).
Num.is_length(val: int | float) -> bool
Returns true if the given number has length units.
Num.is_mass(val: int | float) -> bool
Returns true if the given number has units of mass.
Num.is_memory(val: int | float) -> bool
Returns true if the given number has units of computer memory (bits, bytes, MB, MiB, KB, etc.).
Num.is_temp(val: int | float) -> bool
Returns true if the given number has temperature units.
Num.is_time(val: int | float) -> bool
Returns true if the given number has units of time.
Num.len(val: int | float) -> int
Length of this number (helpful for iteration).
Num.ln(val: int | float) -> float
Natural log.
Num.log(val: int | float, base: int | float = 10) -> float
Log function with a given base value.
Num.max(..) -> unknown
Return the maximum value of all given arguments. If the argument is a collection, this will get the maximum value within that collection for comparison with the others. Will consider units if provided as well.
Num.min(..) -> unknown
Return the minimum value of all given arguments. If the argument is a collection, this will get the minimum value within that collection for comparison with the others. Will consider units if provided as well.
Num.nan(val: int | float) -> bool
Return true if this value is NaN.
Num.oct(val: int) -> str
Returns this number represented as an octal string.
Num.pow(val: int | float, to: int | float = 2) -> float
Returns the given value raised to the given power.
Num.remove_units(val: int | float) -> int | float
Removes the units (if any) on this number.
Num.round(val: int | float, places: int = 0) -> int | float
Round the given number to the given number of places. If value is an integer, do nothing.
Num.signum(val: int | float) -> int | float
Return a number representing the sign of this value (-1 or 1).
Num.sin(val: int | float) -> float
Sine function.
Num.sinh(val: int | float) -> float
Hyperbolic Sine function.
Num.sqrt(val: int | float) -> float
Return the square root of a number.
Num.tan(val: int | float) -> float
Tangent function.
Num.tanh(val: int | float) -> float
Hyperbolic Tangent function.
Num.to_string(val: int | float) -> str
Returns this number represented as a string (like print).
Num.to_units(val: int | float, units: str | float) -> units
Returns val cast to the given units (either a str or another number with units).
Num.trunc(val: int | float) -> int | float
Return the integer part of the given value.
Last updated