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 square root of a number.
Returns NaN if self
is a negative number other than -0.0
.
Examples
let positive = 4.0_f64;
let negative = -4.0_f64;
let negative_zero = -0.0_f64;
let abs_difference = .abs;
assert!;
assert!;
assert!;
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!;
Returns the largest integer less than or equal to self
.
Examples
let f = 3.7_f64;
let g = 3.0_f64;
let h = -3.7_f64;
assert!;
assert!;
assert!;
Returns the smallest integer greater than or equal to self
.
Examples
let f = 3.01_f64;
let g = 4.0_f64;
assert_eq!;
assert_eq!;
Returns the nearest integer to self
. If a value is half-way between two integers, round away from 0.0
.
Examples
let f = 3.3_f64;
let g = -3.3_f64;
let h = -3.7_f64;
let i = 3.5_f64;
let j = 4.5_f64;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Trait Implementations
Clone the specified value
.
Examples
let a = 42;
let b = a;
let c = a.clone;
a += 1;
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values for equality.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values for inequality.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values.
Examples
use Ordering;
assert_eq!;
assert_eq!;
assert_eq!;
Tests less than (for self
and other
) and is used by the <
operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests less than or equal to (for self
and other
) and is used by the <=
operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests greater than (for self
and other
) and is used by the >
operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests greater than or equal to (for self
and other
) and is used by the >=
operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values.
Examples
use Ordering;
assert_eq!;
assert_eq!;
assert_eq!;
Return the minimum of two values.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Return the maximum of two values.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Protocols
$a.max
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!;
$a.min
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!;
let $out = clone
Clone a f64
.
Note that since the type is copy, cloning has the same effect as assigning it.
Examples
let a = 5.0;
let b = a;
let c = a.clone;
a += 1.0;
assert_eq!;
assert_eq!;
assert_eq!;
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 totally ordered comparison between two floats.
Examples
use Ordering;
use cmp;
assert_eq!;
assert_eq!;
assert_eq!;