Operations and constants for f64
NaN
digits
epsilon
infinity
mantissa_digits
max_10_exp
max_exp
max_value
min_10_exp
min_exp
min_value
neg_infinity
radix
of Num for f64
of Eq for f64
of ApproxEq<f64> for f64
of Ord for f64
of Orderable for f64
of Zero for f64
of One for f64
of Add<f64, f64> for f64
of Sub<f64, f64> for f64
of Mul<f64, f64> for f64
of Div<f64, f64> for f64
of Rem<f64, f64> for f64
of Neg<f64> for f64
of Signed for f64
of Round for f64
of Fractional for f64
of Algebraic for f64
of Trigonometric for f64
of Exponential for f64
of Hyperbolic for f64
of Real for f64
of RealExt for f64
of Bounded for f64
of Primitive for f64
of Float for f64
of to_str::ToStr for f64
of num::ToStrRadix for f64
of FromStr for f64
of num::FromStrRadix for f64
add
div
eq
fmax
fmin
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.ge
gt
le
lt
mul
ne
rem
sub
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 valuef64::consts
NaN
f64
digits
uint
epsilon
f64
infinity
f64
mantissa_digits
uint
max_10_exp
int
max_exp
int
max_value
f64
min_10_exp
int
min_exp
int
min_value
f64
neg_infinity
f64
radix
uint
Num
for f64
Eq
for f64
eq
fn eq(&self, other: &f64) -> bool
ne
fn ne(&self, other: &f64) -> bool
ApproxEq<f64>
for f64
approx_epsilon
fn approx_epsilon() -> f64
approx_eq
fn approx_eq(&self, other: &f64) -> bool
approx_eq_eps
fn approx_eq_eps(&self, other: &f64, approx_epsilon: &f64) -> bool
Ord
for f64
lt
fn lt(&self, other: &f64) -> bool
le
fn le(&self, other: &f64) -> bool
ge
fn ge(&self, other: &f64) -> bool
gt
fn gt(&self, other: &f64) -> bool
Orderable
for f64
min
fn min(&self, other: &f64) -> f64
Returns NaN
if either of the numbers are NaN
.
max
fn max(&self, other: &f64) -> f64
Returns NaN
if either of the numbers are NaN
.
clamp
fn clamp(&self, mn: &f64, mx: &f64) -> f64
Returns the number constrained within the range mn <= self <= mx
. If any of the numbers are NaN
then NaN
is returned.
Zero
for f64
zero
fn zero() -> f64
is_zero
fn is_zero(&self) -> bool
Returns true if the number is equal to either 0.0
or -0.0
One
for f64
one
fn one() -> f64
Add<f64, f64>
for f64
add
fn add(&self, other: &f64) -> f64
Sub<f64, f64>
for f64
sub
fn sub(&self, other: &f64) -> f64
Mul<f64, f64>
for f64
mul
fn mul(&self, other: &f64) -> f64
Div<f64, f64>
for f64
div
fn div(&self, other: &f64) -> f64
Rem<f64, f64>
for f64
rem
fn rem(&self, other: &f64) -> f64
Neg<f64>
for f64
neg
fn neg(&self) -> f64
Signed
for f64
abs
fn abs(&self) -> f64
Computes the absolute value. Returns NaN
if the number is NaN
.
abs_sub
fn abs_sub(&self, other: &f64) -> f64
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) -> f64
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
Round
for f64
floor
fn floor(&self) -> f64
Round half-way cases toward neg_infinity
ceil
fn ceil(&self) -> f64
Round half-way cases toward infinity
round
fn round(&self) -> f64
Round half-way cases away from 0.0
trunc
fn trunc(&self) -> f64
The integer part of the number (rounds towards 0.0
)
fract
fn fract(&self) -> f64
The fractional part of the number, satisfying:
assert!(x == trunc(x) + fract(x))
Fractional
for f64
recip
fn recip(&self) -> f64
The reciprocal (multiplicative inverse) of the number
Algebraic
for f64
pow
fn pow(&self, n: &f64) -> f64
sqrt
fn sqrt(&self) -> f64
rsqrt
fn rsqrt(&self) -> f64
cbrt
fn cbrt(&self) -> f64
hypot
fn hypot(&self, other: &f64) -> f64
Trigonometric
for f64
sin
fn sin(&self) -> f64
cos
fn cos(&self) -> f64
tan
fn tan(&self) -> f64
asin
fn asin(&self) -> f64
acos
fn acos(&self) -> f64
atan
fn atan(&self) -> f64
atan2
fn atan2(&self, other: &f64) -> f64
sin_cos
fn sin_cos(&self) -> (f64, f64)
Simultaneously computes the sine and cosine of the number
Exponential
for f64
exp
fn exp(&self) -> f64
Returns the exponential of the number
exp2
fn exp2(&self) -> f64
Returns 2 raised to the power of the number
ln
fn ln(&self) -> f64
Returns the natural logarithm of the number
log
fn log(&self, base: &f64) -> f64
Returns the logarithm of the number with respect to an arbitrary base
log2
fn log2(&self) -> f64
Returns the base 2 logarithm of the number
log10
fn log10(&self) -> f64
Returns the base 10 logarithm of the number
Hyperbolic
for f64
sinh
fn sinh(&self) -> f64
cosh
fn cosh(&self) -> f64
tanh
fn tanh(&self) -> f64
asinh
fn asinh(&self) -> f64
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) -> f64
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) -> f64
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 f64
pi
fn pi() -> f64
Archimedes' constant
two_pi
fn two_pi() -> f64
2.0 * pi
frac_pi_2
fn frac_pi_2() -> f64
pi / 2.0
frac_pi_3
fn frac_pi_3() -> f64
pi / 3.0
frac_pi_4
fn frac_pi_4() -> f64
pi / 4.0
frac_pi_6
fn frac_pi_6() -> f64
pi / 6.0
frac_pi_8
fn frac_pi_8() -> f64
pi / 8.0
frac_1_pi
fn frac_1_pi() -> f64
1.0 / pi
frac_2_pi
fn frac_2_pi() -> f64
2.0 / pi
frac_2_sqrtpi
fn frac_2_sqrtpi() -> f64
2.0 / sqrt(pi)
sqrt2
fn sqrt2() -> f64
sqrt(2.0)
frac_1_sqrt2
fn frac_1_sqrt2() -> f64
1.0 / sqrt(2.0)
e
fn e() -> f64
Euler's number
log2_e
fn log2_e() -> f64
log2(e)
log10_e
fn log10_e() -> f64
log10(e)
ln_2
fn ln_2() -> f64
ln(2.0)
ln_10
fn ln_10() -> f64
ln(10.0)
to_degrees
fn to_degrees(&self) -> f64
Converts to degrees, assuming the number is in radians
to_radians
fn to_radians(&self) -> f64
Converts to radians, assuming the number is in degrees
RealExt
for f64
lgamma
fn lgamma(&self) -> (int, f64)
tgamma
fn tgamma(&self) -> f64
j0
fn j0(&self) -> f64
j1
fn j1(&self) -> f64
jn
fn jn(&self, n: int) -> f64
y0
fn y0(&self) -> f64
y1
fn y1(&self) -> f64
yn
fn yn(&self, n: int) -> f64
Bounded
for f64
min_value
fn min_value() -> f64
max_value
fn max_value() -> f64
Primitive
for f64
bits
fn bits() -> uint
bytes
fn bytes() -> uint
Float
for f64
NaN
fn NaN() -> f64
infinity
fn infinity() -> f64
neg_infinity
fn neg_infinity() -> f64
neg_zero
fn neg_zero() -> f64
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() -> f64
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: f64, exp: int) -> f64
Constructs a floating point number by multiplying x
by 2 raised to the power of exp
frexp
fn frexp(&self) -> (f64, 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) -> f64
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) -> f64
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: f64, b: f64) -> f64
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: f64) -> f64
Returns the next representable floating-point value in the direction of other
to_str::ToStr
for f64
to_str
fn to_str(&self) -> ~str
num::ToStrRadix
for f64
to_str_radix
fn to_str_radix(&self, rdx: uint) -> ~str
FromStr
for f64
from_str
fn from_str(val: &str) -> Option<f64>
num::FromStrRadix
for f64
from_str_radix
fn from_str_radix(val: &str, rdx: uint) -> Option<f64>
add
fn add(x: f64, y: f64) -> f64
div
fn div(x: f64, y: f64) -> f64
eq
fn eq(x: f64, y: f64) -> bool
fmax
fn fmax(x: f64, y: f64) -> f64
fmin
fn fmin(x: f64, y: f64) -> f64
from_str
fn from_str(num: &str) -> Option<f64>
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<f64>
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, rdx: uint) -> Option<f64>
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
.
ge
fn ge(x: f64, y: f64) -> bool
gt
fn gt(x: f64, y: f64) -> bool
le
fn le(x: f64, y: f64) -> bool
lt
fn lt(x: f64, y: f64) -> bool
mul
fn mul(x: f64, y: f64) -> f64
ne
fn ne(x: f64, y: f64) -> bool
rem
fn rem(x: f64, y: f64) -> f64
sub
fn sub(x: f64, y: f64) -> f64
to_str
fn to_str(num: f64) -> ~str
Converts a float to a string
to_str_digits
fn to_str_digits(num: f64, dig: uint) -> ~str
Converts a float to a string with a maximum number of significant digits
to_str_exact
fn to_str_exact(num: f64, dig: uint) -> ~str
Converts a float to a string with exactly the number of provided significant digits
to_str_hex
fn to_str_hex(num: f64) -> ~str
Converts a float to a string in hexadecimal format
to_str_radix
fn to_str_radix(num: f64, rdx: 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: f64, rdx: uint) -> (~str, bool)
Converts a float to a string in a given radix, and a flag indicating whether it's a special value