[−][src]Struct rug::float::OrdFloat
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 core::cmp::Ordering; use rug::{ float::{OrdFloat, Special}, Float, }; 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);
Implementations
impl OrdFloat
[src]
pub fn as_float(&self) -> &Float
[src]
Extracts the underlying Float
.
The same result can be obtained using the implementation of
AsRef<Float>
which is
provided for OrdFloat
.
Examples
use rug::{float::OrdFloat, Float}; 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]
Extracts the underlying Float
.
The same result can be obtained using the implementation of
AsMut<Float>
which is
provided for OrdFloat
.
Examples
use rug::{float::OrdFloat, Float}; let f = Float::with_val(53, -1.5); let mut ord = OrdFloat::from(f); ord.as_float_mut().abs_mut(); assert_eq!(ord.as_float().to_f64(), 1.5);
Trait Implementations
impl AsMut<Float> for OrdFloat
[src]
impl AsRef<Float> for OrdFloat
[src]
impl AsRef<OrdFloat> for Float
[src]
impl Clone for OrdFloat
[src]
impl Debug for OrdFloat
[src]
impl<'de> Deserialize<'de> for OrdFloat
[src]
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> Result<OrdFloat, D::Error>
[src]
deserializer: D
) -> Result<OrdFloat, D::Error>
fn deserialize_in_place<D: Deserializer<'de>>(
deserializer: D,
place: &mut OrdFloat
) -> Result<(), D::Error>
[src]
deserializer: D,
place: &mut OrdFloat
) -> Result<(), D::Error>
impl Eq for OrdFloat
[src]
impl From<Float> for OrdFloat
[src]
impl From<OrdFloat> for Float
[src]
impl Hash for OrdFloat
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for OrdFloat
[src]
fn cmp(&self, other: &OrdFloat) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<OrdFloat> for OrdFloat
[src]
impl PartialOrd<OrdFloat> for OrdFloat
[src]
fn partial_cmp(&self, other: &OrdFloat) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for OrdFloat
[src]
Auto Trait Implementations
impl RefUnwindSafe for OrdFloat
impl Send for OrdFloat
impl Sync for OrdFloat
impl Unpin for OrdFloat
impl UnwindSafe for OrdFloat
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Az for T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CheckedAs for T
[src]
fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
[src]
T: CheckedCast<Dst>,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> OverflowingAs for T
[src]
fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
[src]
T: OverflowingCast<Dst>,
impl<T> SaturatingAs for T
[src]
fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
[src]
T: SaturatingCast<Dst>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> WrappingAs for T
[src]
fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
[src]
T: WrappingCast<Dst>,