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]

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);

Extracts the underlying Float.

Examples

use rug::Float;
use rug::float::OrdFloat;
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 Clone for OrdFloat
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for OrdFloat
[src]

Formats the value using the given formatter.

impl Default for OrdFloat
[src]

Returns the "default value" for a type. Read more

impl Hash for OrdFloat
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialEq for OrdFloat
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for OrdFloat
[src]

impl PartialOrd for OrdFloat
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

This method returns an Ordering between self and other. Read more

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the maximum of two values. Read more

🔬 This is a nightly-only experimental API. (ord_max_min)

Compares and returns the minimum of two values. Read more

impl From<Float> for OrdFloat
[src]

Performs the conversion.