Mathematics v0.1.0

Source
C's <math.h>: the elementary functions and the special floating-point values.

cbrt

pub extern func cbrt(x: float64) -> float64

Computes cube root.

See also: https://en.cppreference.com/c/numeric/math/cbrt

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the argument
yfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the argument
yfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the argument
yfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the argument
yfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the argument
yfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the argument
yfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the argument
expint32the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
basefloat64the value to raise
exponentfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
argfloat64the value to convert
expc_longthe 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

Source

Parameters

NameTypeDescription
argfloat32the value to convert
expc_longthe 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat32the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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

Source

Parameters

NameTypeDescription
xfloat64the 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.

Source

HUGE_VALF

pub const HUGE_VALF: float32 = float32::Infinity;

HUGE_VALF: the float form of HUGE_VAL.

Source

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.

Source

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.

Source