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§
- Float
Pow - This extension trait covers shortfall in determinacy from the lack of a
libm
counterpart tof32::powi
. Use this for the common small exponents.
Functions§
- abs
std
- Computes the absolute value of x.
- acos
Non- libm
andstd
- 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].
- acosh
Non- libm
andstd
- Inverse hyperbolic cosine function.
- asin
Non- libm
andstd
- 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].
- asinh
Non- libm
andstd
- Inverse hyperbolic sine function.
- atan
Non- libm
andstd
- Computes the arctangent of a number. Return value is in radians in the range [-pi/2, pi/2];
- atan2
Non- libm
andstd
- Computes the four-quadrant arctangent of
y
andx
in radians. - atanh
Non- libm
andstd
- Inverse hyperbolic tangent function.
- cbrt
Non- libm
andstd
- Returns the cube root of a number.
- ceil
std
- Returns the smallest integer greater than or equal to
x
. - copysign
std
- Returns a number composed of the magnitude of
x
and the sign ofy
. - cos
Non- libm
andstd
- Computes the cosine of a number (in radians).
- cosh
Non- libm
andstd
- Hyperbolic cosine function.
- exp
Non- libm
andstd
- Returns
e^(self)
, (the exponential function). - exp2
Non- libm
andstd
- Returns
2^(self)
. - exp_m1
Non- libm
andstd
- Returns
e^(self) - 1
in a way that is accurate even if the number is close to zero. - floor
std
- Returns the largest integer less than or equal to
x
. - fract
std
- Returns the fractional part of
x
. - hypot
Non- libm
andstd
- 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 lengthx.abs()
andy.abs()
. - ln
Non- libm
andstd
- Returns the natural logarithm of the number.
- ln_1p
Non- libm
andstd
- Returns
ln(1+n)
(natural logarithm) more accurately than if the operations were performed separately. - log2
Non- libm
andstd
- Returns the base 2 logarithm of the number.
- log10
Non- libm
andstd
- Returns the base 10 logarithm of the number.
- powf
Non- libm
andstd
- Raises a number to a floating point power.
- rem_
euclid std
- Calculates the least nonnegative remainder of
x (mod y)
. - round
std
- Returns the nearest integer to
x
. If a value is half-way between two integers, round away from0.0
. - sin
Non- libm
andstd
- Computes the sine of a number (in radians).
- sin_cos
Non- libm
andstd
- Simultaneously computes the sine and cosine of the number,
x
. Returns(sin(x), cos(x))
. - sinh
Non- libm
andstd
- Hyperbolic sine function.
- sqrt
std
- Returns the square root of a number.
- tan
Non- libm
andstd
- Computes the tangent of a number (in radians).
- tanh
Non- libm
andstd
- Hyperbolic tangent function.