Builtin type std::prelude::f64
Double precision floating point type
Methods
impl f64 { ... }
-
Parses a floating point number from a string.
Returns
Option::none()if the string does not represent a valid floating point number.Example
assert_eq!(f64::parse("3.1415"), Option::some(3.1415)); assert_eq!(f64::parse("inf"), Option::some(f64::infinity()));Run this example -
Returns
trueif the number has a negative sign,falseotherwise. -
fn max_value() -> f64
Returns the maximum value of
f64 -
fn min_value() -> f64
Returns the minimum value of
f64 -
fn min_positive() -> f64
Returns the smallest positive value of
f64. -
fn epsilon() -> f64
Returns the machine epsilon for
f64. -
Create
f64from raw bitsExample
let f = f64::from_bits(0x400921fb54442d18); assert_eq!(f, std::math::PI);Run this example -
Returns the raw bits of
selfExample
let x = 1.0f64; assert_eq!(x.to_bits(), 0x3ff0000000000000u64);Run this example -
Returns the smallest floating point number strictly greater than
self.If
selfis NaN or positive infinity, it returnsselfunchanged.Example
assert_eq!(0.0.next_up(), 5.0e-324); assert_eq!(1.0.next_up(), 1.0000000000000002); assert_eq!((-1.0).next_up(), -0.9999999999999999); assert_eq!(f64::neg_infinity().next_up(), -1.7976931348623157e308); assert_eq!(f64::infinity().next_up(), f64::infinity()); assert!(f64::nan().next_up().is_nan());Run this example -
Returns the largest floating point number strictly less than
self.If
selfis NaN or negative infinity, it returnsselfunchanged.Example
assert_eq!(0.0.next_down(), -5.0e-324); assert_eq!(1.0.next_down(), 0.9999999999999999); assert_eq!((-1.0).next_down(), -1.0000000000000002); assert_eq!(f64::neg_infinity().next_down(), f64::neg_infinity()); assert_eq!(f64::infinity().next_down(), 1.7976931348623157e308); assert!(f64::nan().next_down().is_nan());Run this example -
Inverse cosine
-
Inverse sine
-
Inverse tangent
-
Four-quadrant inverse tangent
-
Inverse hyperbolic cosine
-
Cube root
-
Ceiling of number
-
Cosine
-
Hyperbolic cosine
-
Gauss error function
-
Complementary error function (1 - erf(self))
-
Exponential function (e^
self) -
Floor of number
-
Natural logarithm
-
Base 2 logarithm
-
Base 10 logarithm
-
Decompose
selfinto a whole and fractional part -
Power function
-
Rounds
selfto the closest integer.If the number is halfway between two integers, it is rounded away from zero.
-
Sine function
-
Hyperbolic sine function
-
Square root
-
Tangent function
-
Hyperbolic tangent function
-
Returns the integer part of
self(round towards zero).
Mixins
impl f64 { ... }
-
mixin BuiltinComparable<f64>
-
Returns
falseif arguments are equal,trueotherwise -
Returns
trueiflhsis strictly less thanrhs,falseotherwise -
Returns
trueiflhsis less or equal torhs,falseotherwise -
Returns
trueiflhsstrictly greater thanrhs,falseotherwise -
Returns
trueiflhsgreater than or equalrhs,falseotherwise -
mixin<F> FloatFormattable<f64, F>
F: Formatter<F> -
-
fn nan() -> Self
Returns
NaN. -
fn infinity() -> Self
Returns a positive infinity.
-
fn neg_infinity() -> Self
Returns a negative infinity.
-
Returns
trueif the number is NaN,falseotherwise. -
Returns
trueif the number is infinite,falseotherwise. -
Returns
trueif the number is neither infinite nor NaN,falseotherwise.