Type ::std::f64
The primitive float type.
Methods
Returns true
if this value is NaN.
Examples
let nan = f64NAN;
let f = 7.0_f64;
assert!;
assert!;
Returns true
if this value is positive infinity or negative infinity, and false
otherwise.
Examples
let f = 7.0f64;
let inf = f64INFINITY;
let neg_inf = f64NEG_INFINITY;
let nan = f64NAN;
assert!;
assert!;
assert!;
assert!;
Returns true
if this number is neither infinite nor NaN.
Examples
let f = 7.0f64;
let inf = f64INFINITY;
let neg_inf = f64NEG_INFINITY;
let nan = f64NAN;
assert!;
assert!;
assert!;
assert!;
Returns true
if the number is subnormal.
Examples
let min = f64MIN_POSITIVE; // 2.2250738585072014e-308_f64
let max = f64MAX;
let lower_than_min = 1.0e-308_f64;
let zero = 0.0_f64;
assert!;
assert!;
assert!;
assert!;
assert!;
// Values between `0` and `min` are Subnormal.
assert!;
Returns true
if the number is neither zero, infinite, subnormal, or NaN.
Examples
let min = f64MIN_POSITIVE; // 2.2250738585072014e-308f64
let max = f64MAX;
let lower_than_min = 1.0e-308_f64;
let zero = 0.0f64;
assert!;
assert!;
assert!;
assert!;
assert!;
// Values between `0` and `min` are Subnormal.
assert!;
Returns the maximum of the two numbers, ignoring NaN.
If one of the arguments is NaN, then the other argument is returned. This follows the IEEE 754-2008 semantics for maxNum, except for handling of signaling NaNs; this function handles all NaNs the same way and avoids maxNum's problems with associativity. This also matches the behavior of libm’s fmax.
Examples
let x = 1.0_f64;
let y = 2.0_f64;
assert_eq!;
Returns the minimum of the two numbers, ignoring NaN.
If one of the arguments is NaN, then the other argument is returned. This follows the IEEE 754-2008 semantics for minNum, except for handling of signaling NaNs; this function handles all NaNs the same way and avoids minNum's problems with associativity. This also matches the behavior of libm’s fmin.
Examples
let x = 1.0_f64;
let y = 2.0_f64;
assert_eq!;
Computes the absolute value of self
.
Examples
let x = 3.5_f64;
let y = -3.5_f64;
let abs_difference_x = .abs;
let abs_difference_y = .abs;
assert!;
assert!;
assert!;
Raises a number to a floating point power.
Examples
let x = 2.0_f64;
let abs_difference = .abs;
assert!;
Raises a number to an integer power.
Using this function is generally faster than using powf
. It might have a different sequence of rounding operations than powf
, so the results are not guaranteed to agree.
Examples
let x = 2.0_f64;
let abs_difference = .abs;
assert!;
Protocols
if value == b
Test two floats for partial equality.
Examples
assert!;
assert!;
assert!;
assert!;
assert!;
if value == b
Test two floats for total equality.
Examples
use eq;
assert_eq!;
assert_eq!;
assert_eq!;
if value < b
Perform a partial ordered comparison between two floats.
Examples
use Ordering;
use partial_cmp;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
if value < b
Perform a partial ordered comparison between two floats.
Examples
use Ordering;
use cmp;
assert_eq!;
assert_eq!;
assert_eq!;