Struct rug::float::OrdFloat
[−]
[src]
pub struct OrdFloat { /* fields omitted */ }
A float that supports total ordering and hashing.
Negative zero is ordered as less than positive zero. Negative NaN is ordered as less than negative infinity, while positive NaN is ordered as greater than positive infinity. Comparing two negative NaNs or two positive NaNs produces equality.
Examples
use rug::Float; use rug::float::{OrdFloat, Special}; use std::cmp::Ordering; let pos_nan_f = Float::with_val(53, Special::Nan); let pos_inf_f = Float::with_val(53, Special::Infinity); let pos_zero_f = Float::with_val(53, Special::Zero); let neg_zero_f = Float::with_val(53, Special::NegZero); let neg_inf_f = Float::with_val(53, Special::NegInfinity); let neg_nan_f = Float::with_val(53, -&pos_nan_f); let pos_nan = OrdFloat::from(pos_nan_f); let pos_inf = OrdFloat::from(pos_inf_f); let pos_zero = OrdFloat::from(pos_zero_f); let neg_zero = OrdFloat::from(neg_zero_f); let neg_inf = OrdFloat::from(neg_inf_f); let neg_nan = OrdFloat::from(neg_nan_f); assert_eq!(pos_nan.cmp(&pos_nan), Ordering::Equal); assert_eq!(neg_nan.cmp(&neg_nan), Ordering::Equal); assert_eq!(neg_nan.cmp(&pos_nan), Ordering::Less); assert_eq!(pos_nan.cmp(&pos_inf), Ordering::Greater); assert_eq!(neg_nan.cmp(&neg_inf), Ordering::Less); assert_eq!(pos_zero.cmp(&neg_zero), Ordering::Greater);
Methods
impl OrdFloat
[src]
pub fn as_float(&self) -> &Float
[src]
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);
pub fn as_float_mut(&mut self) -> &mut Float
[src]
Trait Implementations
impl Clone for OrdFloat
[src]
fn clone(&self) -> OrdFloat
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for OrdFloat
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Hash for OrdFloat
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Eq for OrdFloat
[src]
impl Ord for OrdFloat
[src]
fn cmp(&self, other: &OrdFloat) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl PartialEq for OrdFloat
[src]
fn eq(&self, other: &OrdFloat) -> bool
[src]
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[src]
This method tests for !=
.
impl PartialOrd for OrdFloat
[src]
fn partial_cmp(&self, other: &OrdFloat) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
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[src]
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[src]
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[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl From<Float> for OrdFloat
[src]
impl From<OrdFloat> for Float
[src]
impl Serialize for OrdFloat
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for OrdFloat
[src]
fn deserialize<D>(deserializer: D) -> Result<OrdFloat, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
fn deserialize_in_place<D>(
deserializer: D,
place: &mut OrdFloat
) -> Result<(), D::Error> where
D: Deserializer<'de>,
[src]
deserializer: D,
place: &mut OrdFloat
) -> Result<(), D::Error> where
D: Deserializer<'de>,