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
true
if the number has a negative sign,false
otherwise. -
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
f64
from raw bitsExample
let f = f64::from_bits(0x400921fb54442d18); assert_eq!(f, std::math::PI);
Run this example -
Returns the raw bits of
self
Example
let x = 1.0f64; assert_eq!(x.to_bits(), 0x3ff0000000000000u64);
Run this example -
Returns the smallest floating point number strictly greater than
self
.If
self
is NaN or positive infinity, it returnsself
unchanged.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
self
is NaN or negative infinity, it returnsself
unchanged.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
self
into a whole and fractional part -
Power function
-
Rounds
self
to 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
false
if arguments are equal,true
otherwise -
Returns
true
iflhs
is strictly less thanrhs
,false
otherwise -
Returns
true
iflhs
is less or equal torhs
,false
otherwise -
Returns
true
iflhs
strictly greater thanrhs
,false
otherwise -
Returns
true
iflhs
greater than or equalrhs
,false
otherwise -
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
true
if the number is NaN,false
otherwise. -
Returns
true
if the number is infinite,false
otherwise. -
Returns
true
if the number is neither infinite nor NaN,false
otherwise.