Number Library
Stof's standard number library ("Number").
See Primitive Types, Units, and Casting/Conversions for more information on number types in Stof.
Common Value Functions
Number.toString(val: int | float | units): str
Number.or(val: int | float | units, ...): unknown
Returns the first non-empty (null or void) argument, just like the Standard Library "or" function.
Number Functions
Number.round(val: int | float | units, places?: int): float
Round this val to the nearest integer. If value is half-way between two integers, rounds away from 0.0. If given a number of places to round to, move the decimal right that many places, round, then moves it back.
Number.pow(val: int | float | units, power: int | float): float
Raises a number to a power.
Number.sqrt(val: int | float | units): float
Return the square root of a number.
Number.cbrt(val: int | float | units): float
Return the cube root of a number.
Number.abs(val: int | float | units): float
Return the absolute value of a number.
Number.floor(val: int | float | units): float
Return the largest integer less than or equal to "val".
Number.ceil(val: int | float | units): float
Return the smallest integer greater than or equal to "val".
Number.trunc(val: int | float | units): float
Return the integer part of "val". Non-integer values are always truncated towards zero.
Number.fract(val: int | float | units): float
Return the fractional part of "val".
Number.signum(val: int | float | units): float
Returns a number representing the sign of "val".
1, the number is positive
-1, the number is negative
Number.exp(val: int | float | units): float
Returns the exponential function e^(val)
.
Number.exp2(val: int | float | units): float
Returns 2^(val)
.
Number.ln(val: int | float | units): float
Returns the natural log of val: ln(val)
.
Number.log(val: int | float | units, base: int | float): float
Returns the logarithm of the number with respect to an arbitrary base.
Number.sin(val: int | float | units): float
Computes the sine of a number (in radians).
Number.cos(val: int | float | units): float
Computes the cosine of a number (in radians).
Number.tan(val: int | float | units): float
Computes the tangent of a number (in radians).
Number.asin(val: int | float | units): rad
Computes the arcsine of a number. Return value is in radians in the range -pi/2, pi/2 or null if the number is outside the range -1, 1.
Number.acos(val: int | float | units): rad
Computes the arccosine of a number. Return value is in radians in the range 0, pi or null if the number is outside the range -1, 1.
Number.atan(val: int | float | units): rad
Computes the arctangent of a number. Return value is in radians in the range -pi/2, pi/2.
Number.atan2(val: int | float | units, other: float): rad
Computes the four quadrant arctangent of "val" and "other" in radians.
x = 0
,y = 0
:0
x >= 0
:arctan(y/x)
->[-pi/2, pi/2]
y >= 0
:arctan(y/x) + pi
->(pi/2, pi]
y < 0
:arctan(y/x) - pi
->(-pi, -pi/2)
Number.sinh(val: int | float | units): float
Hyperbolic sine function.
Number.cosh(val: int | float | units): float
Hyperbolic cosine function.
Number.tanh(val: int | float | units): float
Hyperbolic tangent function.
Number.asinh(val: int | float | units): float
Inverse hyperbolic sine function.
Number.acosh(val: int | float | units): float
Inverse hyperbolic cosine function.
Number.atanh(val: int | float | units): float
Inverse hyperbolic tangent function.
Iteration
Number.len(val: int | float | units): int
Returns the integer part of "val". Non-integer values are truncated towards zero.
This function is provided to support iteration of numbers.
Number.at(val: int | float | units, index: int): int
Returns the integer part of "index" if index is less than the integer part of "val", otherwise, returns the integer part of "val". Non-integer values for both "val" and "index" are truncated towards zero.
Units
Number.units(val: units): str | null
Returns the units of this number or null if no units are defined.
Number.removeUnits(val: units): float
Remove the units of this number if any units are defined. Otherwise, returns a clone of "val".
Number.hasUnits(val: int | float | units): bool
Return true if this number has units defined for it.
Number.isAngle(val: int | float | units): bool
Return true if this number has angle units defined for it.
Number.isDegrees(val: int | float | units): bool
Return true if this number has angle units of Degrees.
Number.isRadians(val: int | float | units): bool
Return true if this number has angle units of Radians.
Number.isPositiveDegrees(val: int | float | units): bool
Return true if this number has angle units of Positive Degrees. See Units for more information on positive degrees.
Number.isPositiveRadians(val: int | float | units): bool
Return true if this number has angle units of Positive Radians. See Units for more information on positive radians.
Number.isTemperature(val: int | float | units): bool
Return true if this number has units of temperature defined for it.
Number.isLength(val: int | float | units): bool
Return true if this number has units of length defined for it.
Number.isTime(val: int | float | units): bool
Return true if this number has units of time defined for it.
Number.isMass(val: int | float | units): bool
Return true if this number has units of mass defined for it.
Last updated