Mathematics v0.1.0
cbrt
pub extern func cbrt(x: float64) -> float64
Computes cube root.
See also: https://en.cppreference.com/c/numeric/math/cbrt
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
ceil
pub extern func ceil(x: float64) -> float64
Computes smallest integer not less than the given value.
See also: https://en.cppreference.com/c/numeric/math/ceil
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
copysign
pub extern func copysign(x: float64, y: float64) -> float64
Copies the sign of a floating-point value.
See also: https://en.cppreference.com/c/numeric/math/copysign
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
y | float64 | the second argument |
Returns: the computed value; the linked reference lists every special case
cos
pub extern func cos(x: float64) -> float64
Computes cosine.
See also: https://en.cppreference.com/c/numeric/math/cos
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
exp
pub extern func exp(x: float64) -> float64
Computes e raised to the given power.
See also: https://en.cppreference.com/c/numeric/math/exp
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
fabs
pub extern func fabs(x: float64) -> float64
Computes the absolute value of a floating-point value.
See also: https://en.cppreference.com/c/numeric/math/fabs
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
fdim
pub extern func fdim(x: float64, y: float64) -> float64
Computes positive difference of two floating-point values.
See also: https://en.cppreference.com/c/numeric/math/fdim
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
y | float64 | the second argument |
Returns: the computed value; the linked reference lists every special case
floor
pub extern func floor(x: float64) -> float64
Computes largest integer not greater than the given value.
See also: https://en.cppreference.com/c/numeric/math/floor
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
fmax
pub extern func fmax(x: float64, y: float64) -> float64
Computes larger of two floating-point values.
See also: https://en.cppreference.com/c/numeric/math/fmax
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
y | float64 | the second argument |
Returns: the computed value; the linked reference lists every special case
fmin
pub extern func fmin(x: float64, y: float64) -> float64
Computes smaller of two floating-point values.
See also: https://en.cppreference.com/c/numeric/math/fmin
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
y | float64 | the second argument |
Returns: the computed value; the linked reference lists every special case
fmod
pub extern func fmod(x: float64, y: float64) -> float64
Computes remainder of the floating-point division operation.
See also: https://en.cppreference.com/c/numeric/math/fmod
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
y | float64 | the second argument |
Returns: the computed value; the linked reference lists every special case
hypot
pub extern func hypot(x: float64, y: float64) -> float64
Computes square root of the sum of the squares of two given numbers.
See also: https://en.cppreference.com/c/numeric/math/hypot
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
y | float64 | the second argument |
Returns: the computed value; the linked reference lists every special case
ldexp
pub extern func ldexp(x: float64, exp: int32) -> float64
Multiplies a number by 2 raised to an integer power.
See also: https://en.cppreference.com/c/numeric/math/ldexp
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
exp | int32 | the power of two to multiply by |
Returns: the computed value; the linked reference lists every special case
log
pub extern func log(x: float64) -> float64
Computes natural (base e) logarithm.
See also: https://en.cppreference.com/c/numeric/math/log
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
log2
pub extern func log2(x: float64) -> float64
Computes base 2 logarithm.
See also: https://en.cppreference.com/c/numeric/math/log2
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
pow
pub extern func pow(
base: float64,
exponent: float64
) -> float64
Computes a number raised to the given power.
See also: https://en.cppreference.com/c/numeric/math/pow
Parameters
| Name | Type | Description |
|---|---|---|
base | float64 | the value to raise |
exponent | float64 | the power to raise it to |
Returns: the computed value; the linked reference lists every special case
round
pub extern func round(x: float64) -> float64
Rounds to nearest integer, rounding away from zero in halfway cases.
See also: https://en.cppreference.com/c/numeric/math/round
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
scalbln
pub extern func scalbln(
arg: float64,
exp: c_long
) -> float64
Computes sine. https://en.cppreference.com/c/numeric/math/sin Multiplies a floating-point value by an integral power of two, with a long exponent
See also: https://en.cppreference.com/c/numeric/math/scalbn
Parameters
| Name | Type | Description |
|---|---|---|
arg | float64 | the value to convert |
exp | c_long | the exponent |
Returns: the computed value; the linked reference lists every special case
scalblnf
pub extern func scalblnf(
arg: float32,
exp: c_long
) -> float32
Multiplies a floating-point value by an integral power of two, with a long exponent.
See also: https://en.cppreference.com/c/numeric/math/scalbn
Parameters
| Name | Type | Description |
|---|---|---|
arg | float32 | the value to convert |
exp | c_long | the exponent |
Returns: the computed value; the linked reference lists every special case
sin
pub extern func sin(x: float64) -> float64
Computes sine.
See also: https://en.cppreference.com/c/numeric/math/sin
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
sqrtf
pub extern func sqrtf(x: float32) -> float32
Computes square root.
See also: https://en.cppreference.com/c/numeric/math/sqrt
Parameters
| Name | Type | Description |
|---|---|---|
x | float32 | the argument |
Returns: the computed value; the linked reference lists every special case
sqrt
pub extern func sqrt(x: float64) -> float64
Computes square root.
See also: https://en.cppreference.com/c/numeric/math/sqrt
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
tan
pub extern func tan(x: float64) -> float64
Computes tangent.
See also: https://en.cppreference.com/c/numeric/math/tan
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
trunc
pub extern func trunc(x: float64) -> float64
Rounds to nearest integer not greater in magnitude than the given value.
See also: https://en.cppreference.com/c/numeric/math/trunc
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 | the argument |
Returns: the computed value; the linked reference lists every special case
HUGE_VAL
pub const HUGE_VAL: float64 = float64::Infinity;
HUGE_VAL: what a double function returns when the true result is too large to express.
An infinity on every supported target, which is what the standard permits and what every one of them chooses.
HUGE_VALF
pub const HUGE_VALF: float32 = float32::Infinity;
HUGE_VALF: the float form of HUGE_VAL.
INFINITY
pub const INFINITY: float32 = float32::Infinity;
INFINITY: a positive infinity, for building a value rather than for testing one.
Comparing against it is not how a caller asks whether a result overflowed; Core::IsInfinite answers that without
naming a width.
NAN
pub const NAN: float32 = float32::NaN;
NAN: a quiet not-a-number, for building a value rather than for testing one.
It equals nothing, itself included, so value == NAN is always false and is never the test a caller wants;
Core::IsNaN is.