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
x
with 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
x
with 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
x
and ‘y’, returning the result in radians with an error of less than 1 ULP - atan2d
- Calculates the 2-argument arctangent of
x
and ‘y’, returning the result in degrees, with an error of less than 1 ULP - atan2pi
- Calculates the 2-argument arctangent of
x
and ‘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
x
with 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
x
with and error of less than 1 ULP. - ceil
- Rounds
x
to the nearest integer that is not less thanx
- copysign
- Returns a value with the magnitude of
x
and the sign ofy
- cos
- Calculates the cosine of
x
radians with an error of less than 1 ULP - cosd
- Calculates the cosine of
x
degrees with an error of less than 1 ULP - cosh
- Calculates the hyperbolic cosine of
x
with an error of less than 1 ULP - cospi
- Calculates the cosine of
x
half-revolutions with an error of less than 1 ULP - exp
- Calculates Euler’s number raised to
x
with an error of less than 1 ULP - exp2
- Calculates 2 raised to
x
with an error of less than 1 ULP - exp10
- Calculates 10 raised to
x
with an error of less than 1 ULP - exp_m1
- Calculates
exp(x) - 1.0
with an error of less than 1 ULP - floor
- Rounds
x
to the nearest integer that is not greater thanx
- frexp
- Splits
x
into mantissa and exponent. - hypot
- Calculates the Pythagorean addition of
x
andy
with 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
x
with an error of less than 1 ULP - log2
- Calculates the base-2 logarithm of
x
with an error of less than 1 ULP - log10
- Calculates the base-10 logarithm of
x
with an error of less than 1 ULP - log_1p
- Calculates the natural logarithm of
x + 1
with an error of less than 1 ULP - pow
- Calculates
x
raised toy
with an error of less than 1 ULP - powi
- Calculates
x
raised toy
with an error of less than 1 ULP - round
- Rounds
x
to the nearest integer, ties round away from zero - scalbn
- Calculates
x
times two raised toy
. - sin
- Calculates the sine of
x
radians with an error of less than 1 ULP - sin_cos
- Calculates the sine and the cosine of
x
radians - sind
- Calculates the sine of
x
degrees with an error of less than 1 ULP - sind_
cosd - Calculates the sine and the cosine of
x
degrees - sinh
- Calculates the hyperbolic sine of
x
with an error of less than 1 ULP - sinh_
cosh - Calculates the hyerbolic sine and hyerbolic cosine of
x
- sinpi
- Calculates the sine of
x
half-revolutions with an error of less than 1 ULP - sinpi_
cospi - Calculates the sine and the cosine of
x
half-revolutions - sqrt
- Calculates the square root of
x
with an error of less than 0.5 ULP. - tan
- Calculates the tangent of
x
radians with an error of less than 1 ULP - tand
- Calculates the tangent of
x
degrees with an error of less than 1 ULP - tanh
- Calculates the hyperbolic tangent of
x
with an error of less than 1 ULP - tanpi
- Calculates the tangent of
x
half-revolutions with an error of less than 1 ULP - tgamma
- Calculates the gamma function of
x
- trunc
- Rounds
x
to the nearest integer that is not greater in magnitude thanx