Expand description
A pure-Rust floating point math library with support for native floating point and soft-floats.
This crate is no_std.
The following math functions are implemented:
- Sign operations (
abs,copysign). - Rounding (
round,trunc,ceil,floor). - Exponential (
exp,exp_m1,exp2,exp10). - Logarithmic (
log,log_1p,log2,log10). - Power (
pow,powi). - Trigonometric
- Inverse trigonometric
- Hyperbolic (
sinh,cosh,sinh_cosh,tanh). - Inverse hyperbolic (
asinh,acosh,atanh). - Gamma (
tgamma,lgamma).
All functions are implemted for the native floating point types f32
and f64.
The soft-float types SoftF32 and SoftF64 are also provided. They
also support all the above functions and provide consistent bit-to-bit
behavior across platforms. They are available when the soft-float feature
is enabled (disabled by default).
The FloatMath trait is used to identify types that support the math
functions.
Structs§
- SoftF32
- Software single-precision floating-point number.
- SoftF64
- Software double-precision floating-point number.
Traits§
- Float
Math - Floating point types with math functions.
Functions§
- abs
- Calculates the absolute value of
x - acos
- Calculates the arccosine of
x, returning the result in radians, with an error of less than 1 ULP - acosd
- Calculates the arccosine of
x, returning the result in degrees, with an error of less than 1 ULP - acosh
- Calculates the hyperbolic arccosine of
xwith an error of less than 1 ULP - acospi
- Calculates the arccosine of
x, returning the result in half-revolutions, with an error of less than 1 ULP - asin
- Calculates the arcsine of
x, returning the result in radians, with an error of less than 1 ULP - asind
- Calculates the arcsine of
x, returning the result in degrees, with an error of less than 1 ULP - asinh
- Calculates the hyperbolic arcsine of
xwith an error of less than 1 ULP - asinpi
- Calculates the arcsine of
x, returning the result in half-revolutions, with an error of less than 1 ULP - atan
- Calculates the arctangent of
x, returning the result in radians, with an error of less than 1 ULP - atan2
- Calculates the 2-argument arctangent of
xand ‘y’, returning the result in radians with an error of less than 1 ULP - atan2d
- Calculates the 2-argument arctangent of
xand ‘y’, returning the result in degrees, with an error of less than 1 ULP - atan2pi
- Calculates the 2-argument arctangent of
xand ‘y’, returning the result in half-revolutions, with an error of less than 1 ULP - atand
- Calculates the arctangent of
x, returning the result in degrees, with an error of less than 1 ULP - atanh
- Calculates the hyperbolic arctangent of
xwith an error of less than 1 ULP - atanpi
- Calculates the arctangent of
x, returning the result in half-revolutions, with an error of less than 1 ULP - cbrt
- Calculates the cube root of
xwith and error of less than 1 ULP. - ceil
- Rounds
xto the nearest integer that is not less thanx - copysign
- Returns a value with the magnitude of
xand the sign ofy - cos
- Calculates the cosine of
xradians with an error of less than 1 ULP - cosd
- Calculates the cosine of
xdegrees with an error of less than 1 ULP - cosh
- Calculates the hyperbolic cosine of
xwith an error of less than 1 ULP - cospi
- Calculates the cosine of
xhalf-revolutions with an error of less than 1 ULP - exp
- Calculates Euler’s number raised to
xwith an error of less than 1 ULP - exp2
- Calculates 2 raised to
xwith an error of less than 1 ULP - exp10
- Calculates 10 raised to
xwith an error of less than 1 ULP - exp_m1
- Calculates
exp(x) - 1.0with an error of less than 1 ULP - floor
- Rounds
xto the nearest integer that is not greater thanx - frexp
- Splits
xinto mantissa and exponent. - hypot
- Calculates the Pythagorean addition of
xandywith and error of less than 1 ULP - lgamma
- Calculates the logarithm of the absolute value of the gamma function of
x - log
- Calculates the natural logarithm of
xwith an error of less than 1 ULP - log2
- Calculates the base-2 logarithm of
xwith an error of less than 1 ULP - log10
- Calculates the base-10 logarithm of
xwith an error of less than 1 ULP - log_1p
- Calculates the natural logarithm of
x + 1with an error of less than 1 ULP - pow
- Calculates
xraised toywith an error of less than 1 ULP - powi
- Calculates
xraised toywith an error of less than 1 ULP - round
- Rounds
xto the nearest integer, ties round away from zero - scalbn
- Calculates
xtimes two raised toy. - sin
- Calculates the sine of
xradians with an error of less than 1 ULP - sin_cos
- Calculates the sine and the cosine of
xradians - sind
- Calculates the sine of
xdegrees with an error of less than 1 ULP - sind_
cosd - Calculates the sine and the cosine of
xdegrees - sinh
- Calculates the hyperbolic sine of
xwith an error of less than 1 ULP - sinh_
cosh - Calculates the hyerbolic sine and hyerbolic cosine of
x - sinpi
- Calculates the sine of
xhalf-revolutions with an error of less than 1 ULP - sinpi_
cospi - Calculates the sine and the cosine of
xhalf-revolutions - sqrt
- Calculates the square root of
xwith an error of less than 0.5 ULP. - tan
- Calculates the tangent of
xradians with an error of less than 1 ULP - tand
- Calculates the tangent of
xdegrees with an error of less than 1 ULP - tanh
- Calculates the hyperbolic tangent of
xwith an error of less than 1 ULP - tanpi
- Calculates the tangent of
xhalf-revolutions with an error of less than 1 ULP - tgamma
- Calculates the gamma function of
x - trunc
- Rounds
xto the nearest integer that is not greater in magnitude thanx