Operations and constants for float
NaN
infinity
neg_infinity
of to_str::ToStr for float
of num::ToStrRadix for float
of FromStr for float
of num::FromStrRadix for float
of Num for float
of Eq for float
of ApproxEq<float> for float
of Ord for float
of Orderable for float
of Zero for float
of One for float
of Round for float
of Fractional for float
of Algebraic for float
of Trigonometric for float
of Exponential for float
of Hyperbolic for float
of Real for float
of RealExt for float
of Add<float, float> for float
of Sub<float, float> for float
of Mul<float, float> for float
of Div<float, float> for float
of Rem<float, float> for float
of Neg<float> for float
of Signed for float
of Bounded for float
of Primitive for float
of Float for float
abs
atan
cos
from_str
- Convert a string in base 10 to a floatfrom_str_hex
- Convert a string in base 16 to a floatfrom_str_radix
- Convert a string in an given base to a float.pow_with_uint
- Compute the exponentiation of an integer by another integer as a floatsin
sqrt
tan
to_str
- Converts a float to a stringto_str_digits
- Converts a float to a string with a maximum number of significant digitsto_str_exact
- Converts a float to a string with exactly the number of provided significant digitsto_str_hex
- Converts a float to a string in hexadecimal formatto_str_radix
- Converts a float to a string in a given radixto_str_radix_special
- Converts a float to a string in a given radix, and a flag indicating whether it's a special valuefloat::consts
NaN
float
infinity
float
neg_infinity
float
to_str::ToStr
for float
to_str
fn to_str(&self) -> ~str
num::ToStrRadix
for float
to_str_radix
fn to_str_radix(&self, radix: uint) -> ~str
FromStr
for float
from_str
fn from_str(val: &str) -> Option<float>
num::FromStrRadix
for float
from_str_radix
fn from_str_radix(val: &str, radix: uint) -> Option<float>
Num
for float
Eq
for float
eq
fn eq(&self, other: &float) -> bool
ne
fn ne(&self, other: &float) -> bool
ApproxEq<float>
for float
approx_epsilon
fn approx_epsilon() -> float
approx_eq
fn approx_eq(&self, other: &float) -> bool
approx_eq_eps
fn approx_eq_eps(&self, other: &float, approx_epsilon: &float) -> bool
Ord
for float
lt
fn lt(&self, other: &float) -> bool
le
fn le(&self, other: &float) -> bool
ge
fn ge(&self, other: &float) -> bool
gt
fn gt(&self, other: &float) -> bool
Orderable
for float
min
fn min(&self, other: &float) -> float
Returns NaN
if either of the numbers are NaN
.
max
fn max(&self, other: &float) -> float
Returns NaN
if either of the numbers are NaN
.
clamp
fn clamp(&self, mn: &float, mx: &float) -> float
Returns the number constrained within the range mn <= self <= mx
. If any of the numbers are NaN
then NaN
is returned.
Zero
for float
zero
fn zero() -> float
is_zero
fn is_zero(&self) -> bool
Returns true if the number is equal to either 0.0
or -0.0
One
for float
one
fn one() -> float
Round
for float
floor
fn floor(&self) -> float
Round half-way cases toward neg_infinity
ceil
fn ceil(&self) -> float
Round half-way cases toward infinity
round
fn round(&self) -> float
Round half-way cases away from 0.0
trunc
fn trunc(&self) -> float
The integer part of the number (rounds towards 0.0
)
fract
fn fract(&self) -> float
The fractional part of the number, satisfying:
assert!(x == trunc(x) + fract(x))
Fractional
for float
recip
fn recip(&self) -> float
The reciprocal (multiplicative inverse) of the number
Algebraic
for float
pow
fn pow(&self, n: &float) -> float
sqrt
fn sqrt(&self) -> float
rsqrt
fn rsqrt(&self) -> float
cbrt
fn cbrt(&self) -> float
hypot
fn hypot(&self, other: &float) -> float
Trigonometric
for float
sin
fn sin(&self) -> float
cos
fn cos(&self) -> float
tan
fn tan(&self) -> float
asin
fn asin(&self) -> float
acos
fn acos(&self) -> float
atan
fn atan(&self) -> float
atan2
fn atan2(&self, other: &float) -> float
sin_cos
fn sin_cos(&self) -> (float, float)
Simultaneously computes the sine and cosine of the number
Exponential
for float
exp
fn exp(&self) -> float
Returns the exponential of the number
exp2
fn exp2(&self) -> float
Returns 2 raised to the power of the number
ln
fn ln(&self) -> float
Returns the natural logarithm of the number
log
fn log(&self, base: &float) -> float
Returns the logarithm of the number with respect to an arbitrary base
log2
fn log2(&self) -> float
Returns the base 2 logarithm of the number
log10
fn log10(&self) -> float
Returns the base 10 logarithm of the number
Hyperbolic
for float
sinh
fn sinh(&self) -> float
cosh
fn cosh(&self) -> float
tanh
fn tanh(&self) -> float
asinh
fn asinh(&self) -> float
Inverse hyperbolic sine
self
will be returnedself
if self
is 0.0
, -0.0
, infinity
, or neg_infinity
NaN
if self
is NaN
acosh
fn acosh(&self) -> float
Inverse hyperbolic cosine
self
will be returnedinfinity
if self
is infinity
NaN
if self
is NaN
or self < 1.0
(including neg_infinity
)atanh
fn atanh(&self) -> float
Inverse hyperbolic tangent
self
will be returnedself
if self
is 0.0
or -0.0
infinity
if self
is 1.0
neg_infinity
if self
is -1.0
NaN
if the self
is NaN
or outside the domain of -1.0 <= self <= 1.0
(including infinity
and neg_infinity
)Real
for float
pi
fn pi() -> float
Archimedes' constant
two_pi
fn two_pi() -> float
2.0 * pi
frac_pi_2
fn frac_pi_2() -> float
pi / 2.0
frac_pi_3
fn frac_pi_3() -> float
pi / 3.0
frac_pi_4
fn frac_pi_4() -> float
pi / 4.0
frac_pi_6
fn frac_pi_6() -> float
pi / 6.0
frac_pi_8
fn frac_pi_8() -> float
pi / 8.0
frac_1_pi
fn frac_1_pi() -> float
1.0 / pi
frac_2_pi
fn frac_2_pi() -> float
2.0 / pi
frac_2_sqrtpi
fn frac_2_sqrtpi() -> float
2 .0/ sqrt(pi)
sqrt2
fn sqrt2() -> float
sqrt(2.0)
frac_1_sqrt2
fn frac_1_sqrt2() -> float
1.0 / sqrt(2.0)
e
fn e() -> float
Euler's number
log2_e
fn log2_e() -> float
log2(e)
log10_e
fn log10_e() -> float
log10(e)
ln_2
fn ln_2() -> float
ln(2.0)
ln_10
fn ln_10() -> float
ln(10.0)
to_degrees
fn to_degrees(&self) -> float
Converts to degrees, assuming the number is in radians
to_radians
fn to_radians(&self) -> float
Converts to radians, assuming the number is in degrees
RealExt
for float
lgamma
fn lgamma(&self) -> (int, float)
tgamma
fn tgamma(&self) -> float
j0
fn j0(&self) -> float
j1
fn j1(&self) -> float
jn
fn jn(&self, n: int) -> float
y0
fn y0(&self) -> float
y1
fn y1(&self) -> float
yn
fn yn(&self, n: int) -> float
Add<float, float>
for float
add
fn add(&self, other: &float) -> float
Sub<float, float>
for float
sub
fn sub(&self, other: &float) -> float
Mul<float, float>
for float
mul
fn mul(&self, other: &float) -> float
Div<float, float>
for float
div
fn div(&self, other: &float) -> float
Rem<float, float>
for float
rem
fn rem(&self, other: &float) -> float
Neg<float>
for float
neg
fn neg(&self) -> float
Signed
for float
abs
fn abs(&self) -> float
Computes the absolute value. Returns NaN
if the number is NaN
.
abs_sub
fn abs_sub(&self, other: &float) -> float
The positive difference of two numbers. Returns 0.0
if the number is less than or equal to other
, otherwise the difference betweenself
and other
is returned.
signum
fn signum(&self) -> float
1.0
if the number is positive, +0.0
or infinity
-1.0
if the number is negative, -0.0
or neg_infinity
NaN
if the number is NaNis_positive
fn is_positive(&self) -> bool
Returns true
if the number is positive, including +0.0
and infinity
is_negative
fn is_negative(&self) -> bool
Returns true
if the number is negative, including -0.0
and neg_infinity
Bounded
for float
min_value
fn min_value() -> float
max_value
fn max_value() -> float
Primitive
for float
bits
fn bits() -> uint
bytes
fn bytes() -> uint
Float
for float
NaN
fn NaN() -> float
infinity
fn infinity() -> float
neg_infinity
fn neg_infinity() -> float
neg_zero
fn neg_zero() -> float
is_NaN
fn is_NaN(&self) -> bool
Returns true
if the number is NaN
is_infinite
fn is_infinite(&self) -> bool
Returns true
if the number is infinite
is_finite
fn is_finite(&self) -> bool
Returns true
if the number is neither infinite or NaN
is_normal
fn is_normal(&self) -> bool
Returns true
if the number is neither zero, infinite, subnormal or NaN
classify
fn classify(&self) -> FPCategory
Returns the floating point category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead.
mantissa_digits
fn mantissa_digits() -> uint
digits
fn digits() -> uint
epsilon
fn epsilon() -> float
min_exp
fn min_exp() -> int
max_exp
fn max_exp() -> int
min_10_exp
fn min_10_exp() -> int
max_10_exp
fn max_10_exp() -> int
ldexp
fn ldexp(x: float, exp: int) -> float
Constructs a floating point number by multiplying x
by 2 raised to the power of exp
frexp
fn frexp(&self) -> (float, int)
Breaks the number into a normalized fraction and a base-2 exponent, satisfying:
self = x * pow(2, exp)
0.5 <= abs(x) < 1.0
exp_m1
fn exp_m1(&self) -> float
Returns the exponential of the number, minus 1
, in a way that is accurate even if the number is close to zero
ln_1p
fn ln_1p(&self) -> float
Returns the natural logarithm of the number plus 1
(ln(1+n)
) more accurately than if the operations were performed separately
mul_add
fn mul_add(&self, a: float, b: float) -> float
Fused multiply-add. Computes (self * a) + b
with only one rounding error. This produces a more accurate result with better performance than a separate multiplication operation followed by an add.
next_after
fn next_after(&self, other: float) -> float
Returns the next representable floating-point value in the direction of other
abs
fn abs(x: float) -> float
atan
fn atan(x: float) -> float
cos
fn cos(x: float) -> float
from_str
fn from_str(num: &str) -> Option<float>
Convert a string in base 10 to a float. Accepts a optional decimal exponent.
This function accepts strings such as
Leading and trailing whitespace represent an error.
none
if the string did not represent a valid number. Otherwise, Some(n)
where n
is the floating-point number represented by num
.
from_str_hex
fn from_str_hex(num: &str) -> Option<float>
Convert a string in base 16 to a float. Accepts a optional binary exponent.
This function accepts strings such as
Leading and trailing whitespace represent an error.
none
if the string did not represent a valid number. Otherwise, Some(n)
where n
is the floating-point number represented by [num]
.
from_str_radix
fn from_str_radix(num: &str, radix: uint) -> Option<float>
Convert a string in an given base to a float.
Due to possible conflicts, this function does not accept the special values inf
, -inf
, +inf
and NaN
, nor does it recognize exponents of any kind.
Leading and trailing whitespace represent an error.
none
if the string did not represent a valid number. Otherwise, Some(n)
where n
is the floating-point number represented by num
.
pow_with_uint
fn pow_with_uint(base: uint, pow: uint) -> float
Compute the exponentiation of an integer by another integer as a float
NaN
if both x
and pow
are 0u
, otherwise x^pow
sin
fn sin(x: float) -> float
sqrt
fn sqrt(x: float) -> float
tan
fn tan(x: float) -> float
to_str
fn to_str(num: float) -> ~str
Converts a float to a string
to_str_digits
fn to_str_digits(num: float, digits: uint) -> ~str
Converts a float to a string with a maximum number of significant digits
to_str_exact
fn to_str_exact(num: float, digits: uint) -> ~str
Converts a float to a string with exactly the number of provided significant digits
to_str_hex
fn to_str_hex(num: float) -> ~str
Converts a float to a string in hexadecimal format
to_str_radix
fn to_str_radix(num: float, radix: uint) -> ~str
Converts a float to a string in a given radix
Fails if called on a special value like inf
, -inf
or NaN
due to possible misinterpretation of the result at higher bases. If those values are expected, use to_str_radix_special()
instead.
to_str_radix_special
fn to_str_radix_special(num: float, radix: uint) -> (~str, bool)
Converts a float to a string in a given radix, and a flag indicating whether it's a special value