Module ops

Source
Expand description

This mod re-exports the correct versions of floating-point operations with unspecified precision in the standard library depending on whether the libm crate feature is enabled.

All the functions here are named according to their versions in the standard library.

It also provides no_std compatible alternatives to certain floating-point operations which are not provided in the core library.

Traits§

FloatPow
This extension trait covers shortfall in determinacy from the lack of a libm counterpart to f32::powi. Use this for the common small exponents.

Functions§

absstd
Computes the absolute value of x.
acosNon-libm and std
Computes the arccosine of a number. Return value is in radians in the range [0, pi] or NaN if the number is outside the range [-1, 1].
acoshNon-libm and std
Inverse hyperbolic cosine function.
asinNon-libm and std
Computes the arcsine of a number. Return value is in radians in the range [-pi/2, pi/2] or NaN if the number is outside the range [-1, 1].
asinhNon-libm and std
Inverse hyperbolic sine function.
atanNon-libm and std
Computes the arctangent of a number. Return value is in radians in the range [-pi/2, pi/2];
atan2Non-libm and std
Computes the four-quadrant arctangent of y and x in radians.
atanhNon-libm and std
Inverse hyperbolic tangent function.
cbrtNon-libm and std
Returns the cube root of a number.
ceilstd
Returns the smallest integer greater than or equal to x.
copysignstd
Returns a number composed of the magnitude of x and the sign of y.
cosNon-libm and std
Computes the cosine of a number (in radians).
coshNon-libm and std
Hyperbolic cosine function.
expNon-libm and std
Returns e^(self), (the exponential function).
exp2Non-libm and std
Returns 2^(self).
exp_m1Non-libm and std
Returns e^(self) - 1 in a way that is accurate even if the number is close to zero.
floorstd
Returns the largest integer less than or equal to x.
fractstd
Returns the fractional part of x.
hypotNon-libm and std
Compute the distance between the origin and a point (x, y) on the Euclidean plane. Equivalently, compute the length of the hypotenuse of a right-angle triangle with other sides having length x.abs() and y.abs().
lnNon-libm and std
Returns the natural logarithm of the number.
ln_1pNon-libm and std
Returns ln(1+n) (natural logarithm) more accurately than if the operations were performed separately.
log2Non-libm and std
Returns the base 2 logarithm of the number.
log10Non-libm and std
Returns the base 10 logarithm of the number.
powfNon-libm and std
Raises a number to a floating point power.
rem_euclidstd
Calculates the least nonnegative remainder of x (mod y).
roundstd
Returns the nearest integer to x. If a value is half-way between two integers, round away from 0.0.
sinNon-libm and std
Computes the sine of a number (in radians).
sin_cosNon-libm and std
Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).
sinhNon-libm and std
Hyperbolic sine function.
sqrtstd
Returns the square root of a number.
tanNon-libm and std
Computes the tangent of a number (in radians).
tanhNon-libm and std
Hyperbolic tangent function.