Trait rug::float::AssignRound [] [src]

pub trait AssignRound<Rhs = Self> {
    type Round;
    type Ordering;
    fn assign_round(&mut self, rhs: Rhs, round: Self::Round) -> Self::Ordering;
}

Assignment with a specified rounding method.

Examples

use rug::float::{AssignRound, Round};
use std::cmp::Ordering;
struct F(f64);
impl AssignRound<f64> for F {
    type Round = Round;
    type Ordering = Ordering;
    fn assign_round(&mut self, rhs: f64, _round: Round) -> Ordering {
        self.0 = rhs;
        Ordering::Equal
    }
}
let mut f = F(3.0);
let dir = f.assign_round(5.0, Round::Nearest);
assert_eq!(f.0, 5.0);
assert_eq!(dir, Ordering::Equal);

Associated Types

The rounding method.

The direction from rounding.

Required Methods

Peforms the assignment.

Examples

use rug::Float;
use rug::float::{AssignRound, Round};
use std::cmp::Ordering;
// only four significant bits
let mut f = Float::new(4);
let dir = f.assign_round(3.3, Round::Nearest);
// 3.3 rounded down to 3.25
assert_eq!(f, 3.25);
assert_eq!(dir, Ordering::Less);
let dir = f.assign_round(3.3, Round::Up);
// 3.3 rounded up to 3.5
assert_eq!(f, 3.5);
assert_eq!(dir, Ordering::Greater);

Implementations on Foreign Types

impl<'a> AssignRound<SinCosRef<'a>> for (&'a mut Float, &'a mut Float)
[src]

[src]

impl<'a> AssignRound<SinhCoshRef<'a>> for (&'a mut Float, &'a mut Float)
[src]

[src]

impl<'a> AssignRound<LnAbsGammaRef<'a>> for (&'a mut Float, &'a mut Ordering)
[src]

[src]

impl<'a> AssignRound<TruncFractRef<'a>> for (&'a mut Float, &'a mut Float)
[src]

[src]

impl<'a> AssignRound<SinCosRef<'a>> for (&'a mut Complex, &'a mut Complex)
[src]

[src]

Implementors