Struct rug::float::OrdFloat
[−]
[src]
pub struct OrdFloat { /* fields omitted */ }
A float that supports ordering and hashing.
Negative zero is ordered as less than positive zero. All NaNs are ordered as equal and as less than negative infinity, with the NaN sign ignored.
Examples
use rug::Float; use rug::float::{OrdFloat, Special}; use std::cmp::Ordering; let nan_f = Float::with_val(53, Special::Nan); let nan = OrdFloat::from(nan_f); assert_eq!(nan.cmp(&nan), Ordering::Equal); let neg_inf_f = Float::with_val(53, Special::NegInfinity); let neg_inf = OrdFloat::from(neg_inf_f); assert_eq!(nan.cmp(&neg_inf), Ordering::Less); let zero_f = Float::with_val(53, Special::Zero); let zero = OrdFloat::from(zero_f); let neg_zero_f = Float::with_val(53, Special::NegZero); let neg_zero = OrdFloat::from(neg_zero_f); assert_eq!(zero.cmp(&neg_zero), Ordering::Greater);
Methods
impl OrdFloat
[src]
fn as_float(&self) -> &Float
Extracts the underlying Float
.
Examples
use rug::Float; use rug::float::OrdFloat; let f = Float::with_val(53, 1.5); let ord = OrdFloat::from(f); let f_ref = ord.as_float(); assert_eq!(f_ref.to_f64(), 1.5);
fn as_float_mut(&mut self) -> &mut Float
Trait Implementations
impl Clone for OrdFloat
[src]
fn clone(&self) -> OrdFloat
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for OrdFloat
[src]
impl Default for OrdFloat
[src]
impl Hash for OrdFloat
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for OrdFloat
[src]
fn eq(&self, other: &OrdFloat) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Eq for OrdFloat
[src]
impl PartialOrd for OrdFloat
[src]
fn partial_cmp(&self, other: &OrdFloat) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for OrdFloat
[src]
fn cmp(&self, other: &OrdFloat) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
ord_max_min
)Compares and returns the minimum of two values. Read more