Trait rug::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.

Associated Types

The rounding method.

The direction from rounding.

Required Methods

Peforms the assignment.

Examples

use rug::{AssignRound, Float};
use rug::float::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);

Implementors