Primitive Type f64

Operations and constants for 64-bits floats (f64 type)

Trait Implementations

impl FloatMath for f64

fn ldexp(x: f64, exp: int) -> f64

Constructs a floating point number by multiplying x by 2 raised to the power of exp

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

fn next_after(self, other: f64) -> f64

Returns the next representable floating-point value in the direction of other.

fn max(self, other: f64) -> f64

fn min(self, other: f64) -> f64

fn cbrt(self) -> f64

fn hypot(self, other: f64) -> f64

fn sin(self) -> f64

fn cos(self) -> f64

fn tan(self) -> f64

fn asin(self) -> f64

fn acos(self) -> f64

fn atan(self) -> f64

fn atan2(self, other: f64) -> f64

fn sin_cos(self) -> (f64, f64)

Simultaneously computes the sine and cosine of the number

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

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

fn sinh(self) -> f64

fn cosh(self) -> f64

fn tanh(self) -> f64

fn asinh(self) -> f64

Inverse hyperbolic sine

Returns

  • on success, the inverse hyperbolic sine of self will be returned
  • self if self is 0.0, -0.0, INFINITY, or NEG_INFINITY
  • NAN if self is NAN

fn acosh(self) -> f64

Inverse hyperbolic cosine

Returns

  • on success, the inverse hyperbolic cosine of self will be returned
  • INFINITY if self is INFINITY
  • NAN if self is NAN or self < 1.0 (including NEG_INFINITY)

fn atanh(self) -> f64

Inverse hyperbolic tangent

Returns

  • on success, the inverse hyperbolic tangent of self will be returned
  • self 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)

impl ToStrRadix for f64

fn to_str_radix(&self, rdx: uint) -> String

Converts a float to a string in a given radix

Arguments

  • num - The float value
  • radix - The base to use

Failure

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.

impl FromStr for f64

fn from_str(val: &str) -> Option<f64>

Convert a string in base 10 to a float. Accepts an optional decimal exponent.

This function accepts strings such as

  • '3.14'
  • '+3.14', equivalent to '3.14'
  • '-3.14'
  • '2.5E10', or equivalently, '2.5e10'
  • '2.5E-10'
  • '.' (understood as 0)
  • '5.'
  • '.5', or, equivalently, '0.5'
  • '+inf', 'inf', '-inf', 'NaN'

Leading and trailing whitespace represent an error.

Arguments

  • num - A string

Return value

none if the string did not represent a valid number. Otherwise, Some(n) where n is the floating-point number represented by num.

impl FromStrRadix for f64

fn from_str_radix(val: &str, rdx: uint) -> Option<f64>

Convert a string in a 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.

Arguments

  • num - A string
  • radix - The base to use. Must lie in the range [2 .. 36]

Return value

None if the string did not represent a valid number. Otherwise, Some(n) where n is the floating-point number represented by num.

impl SampleRange for f64

fn construct_range(low: f64, high: f64) -> Range<f64>

fn sample_range<R: Rng>(r: &Range<f64>, rng: &mut R) -> f64

impl Rand for f64

fn rand<R: Rng>(rng: &mut R) -> f64

Generate a floating point number in the half-open interval [0,1).

See Closed01 for the closed interval [0,1], and Open01 for the open interval (0,1).

impl NumStrConv for f64

fn nan() -> Option<f64>

fn inf() -> Option<f64>

fn neg_inf() -> Option<f64>

fn neg_zero() -> Option<f64>

fn round_to_zero(&self) -> f64

fn fractional_part(&self) -> f64

impl Float for f64

fn nan() -> f64

fn infinity() -> f64

fn neg_infinity() -> f64

fn neg_zero() -> f64

fn is_nan(self) -> bool

Returns true if the number is NaN

fn is_infinite(self) -> bool

Returns true if the number is infinite

fn is_finite(self) -> bool

Returns true if the number is neither infinite or NaN

fn is_normal(self) -> bool

Returns true if the number is neither zero, infinite, subnormal or NaN

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.

fn mantissa_digits(Option<f64>) -> uint

fn digits(Option<f64>) -> uint

fn epsilon() -> f64

fn min_exp(Option<f64>) -> int

fn max_exp(Option<f64>) -> int

fn min_10_exp(Option<f64>) -> int

fn max_10_exp(Option<f64>) -> int

fn min_pos_value(Option<f64>) -> f64

fn integer_decode(self) -> (u64, i16, i8)

Returns the mantissa, exponent and sign as integers.

fn floor(self) -> f64

Round half-way cases toward NEG_INFINITY

fn ceil(self) -> f64

Round half-way cases toward INFINITY

fn round(self) -> f64

Round half-way cases away from 0.0

fn trunc(self) -> f64

The integer part of the number (rounds towards 0.0)

fn fract(self) -> f64

The fractional part of the number, satisfying:

fn main() { let x = 1.65f64; assert!(x == x.trunc() + x.fract()) }
let x = 1.65f64;
assert!(x == x.trunc() + x.fract())

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.

fn recip(self) -> f64

The reciprocal (multiplicative inverse) of the number

fn powf(self, n: f64) -> f64

fn powi(self, n: i32) -> f64

fn sqrt2() -> f64

sqrt(2.0)

fn frac_1_sqrt2() -> f64

1.0 / sqrt(2.0)

fn sqrt(self) -> f64

fn rsqrt(self) -> f64

fn pi() -> f64

Archimedes' constant

fn two_pi() -> f64

2.0 * pi

fn frac_pi_2() -> f64

pi / 2.0

fn frac_pi_3() -> f64

pi / 3.0

fn frac_pi_4() -> f64

pi / 4.0

fn frac_pi_6() -> f64

pi / 6.0

fn frac_pi_8() -> f64

pi / 8.0

fn frac_1_pi() -> f64

1.0 / pi

fn frac_2_pi() -> f64

2.0 / pi

fn frac_2_sqrtpi() -> f64

2.0 / sqrt(pi)

fn e() -> f64

Euler's number

fn log2_e() -> f64

log2(e)

fn log10_e() -> f64

log10(e)

fn ln_2() -> f64

ln(2.0)

fn ln_10() -> f64

ln(10.0)

fn exp(self) -> f64

Returns the exponential of the number

fn exp2(self) -> f64

Returns 2 raised to the power of the number

fn ln(self) -> f64

Returns the natural logarithm of the number

fn log(self, base: f64) -> f64

Returns the logarithm of the number with respect to an arbitrary base

fn log2(self) -> f64

Returns the base 2 logarithm of the number

fn log10(self) -> f64

Returns the base 10 logarithm of the number

fn to_degrees(self) -> f64

Converts to degrees, assuming the number is in radians

fn to_radians(self) -> f64

Converts to radians, assuming the number is in degrees

impl Num for f64

impl Zero for f64

fn zero() -> f64

fn is_zero(&self) -> bool

impl One for f64

fn one() -> f64

impl Signed for f64

fn abs(&self) -> f64

Computes the absolute value. Returns NAN if the number is NAN.

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.

fn signum(&self) -> f64

Returns

  • 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 NaN

fn is_positive(&self) -> bool

Returns true if the number is positive, including +0.0 and INFINITY

fn is_negative(&self) -> bool

Returns true if the number is negative, including -0.0 and NEG_INFINITY

impl Bounded for f64

fn min_value() -> f64

fn max_value() -> f64

impl Primitive for f64

impl ToPrimitive for f64

fn to_int(&self) -> Option<int>

fn to_i8(&self) -> Option<i8>

fn to_i16(&self) -> Option<i16>

fn to_i32(&self) -> Option<i32>

fn to_i64(&self) -> Option<i64>

fn to_uint(&self) -> Option<uint>

fn to_u8(&self) -> Option<u8>

fn to_u16(&self) -> Option<u16>

fn to_u32(&self) -> Option<u32>

fn to_u64(&self) -> Option<u64>

fn to_f32(&self) -> Option<f32>

fn to_f64(&self) -> Option<f64>

fn to_int(&self) -> Option<int>

fn to_i8(&self) -> Option<i8>

fn to_i16(&self) -> Option<i16>

fn to_i32(&self) -> Option<i32>

fn to_uint(&self) -> Option<uint>

fn to_u8(&self) -> Option<u8>

fn to_u16(&self) -> Option<u16>

fn to_u32(&self) -> Option<u32>

fn to_f32(&self) -> Option<f32>

fn to_f64(&self) -> Option<f64>

impl FromPrimitive for f64

fn from_int(n: int) -> Option<f64>

fn from_i8(n: i8) -> Option<f64>

fn from_i16(n: i16) -> Option<f64>

fn from_i32(n: i32) -> Option<f64>

fn from_i64(n: i64) -> Option<f64>

fn from_uint(n: uint) -> Option<f64>

fn from_u8(n: u8) -> Option<f64>

fn from_u16(n: u16) -> Option<f64>

fn from_u32(n: u32) -> Option<f64>

fn from_u64(n: u64) -> Option<f64>

fn from_f32(n: f32) -> Option<f64>

fn from_f64(n: f64) -> Option<f64>

fn from_int(int) -> Option<f64>

fn from_i8(i8) -> Option<f64>

fn from_i16(i16) -> Option<f64>

fn from_i32(i32) -> Option<f64>

fn from_uint(uint) -> Option<f64>

fn from_u8(u8) -> Option<f64>

fn from_u16(u16) -> Option<f64>

fn from_u32(u32) -> Option<f64>

fn from_f32(f32) -> Option<f64>

fn from_f64(f64) -> Option<f64>

impl NumCast for f64

fn from<N: ToPrimitive>(n: N) -> Option<f64>

impl Add<f64, f64> for f64

fn add(&self, other: &f64) -> f64

impl Sub<f64, f64> for f64

fn sub(&self, other: &f64) -> f64

impl Mul<f64, f64> for f64

fn mul(&self, other: &f64) -> f64

impl Div<f64, f64> for f64

fn div(&self, other: &f64) -> f64

impl Rem<f64, f64> for f64

fn rem(&self, other: &f64) -> f64

impl Neg<f64> for f64

fn neg(&self) -> f64

impl PartialEq for f64

fn eq(&self, other: &f64) -> bool

fn ne(&self, other: &f64) -> bool

fn ne(&self, &f64) -> bool

impl PartialOrd for f64

fn lt(&self, other: &f64) -> bool

fn le(&self, other: &f64) -> bool

fn ge(&self, other: &f64) -> bool

fn gt(&self, other: &f64) -> bool

fn le(&self, &f64) -> bool

fn gt(&self, &f64) -> bool

fn ge(&self, &f64) -> bool

impl Clone for f64

fn clone(&self) -> f64

Return a deep copy of the value.

fn clone_from(&mut self, &f64)

impl Default for f64

fn default() -> f64

impl Float for f64

fn fmt(&self, fmt: &mut Formatter) -> Result<(), FormatError>

impl LowerExp for f64

fn fmt(&self, fmt: &mut Formatter) -> Result<(), FormatError>

impl UpperExp for f64

fn fmt(&self, fmt: &mut Formatter) -> Result<(), FormatError>

impl<'a> Show for f64

fn fmt<'a>(&self, f: &mut Formatter) -> Result<(), FormatError>