Trait rug::ops::AssignRound
[−]
[src]
pub trait AssignRound<Src = Self> { type Round; type Ordering; fn assign_round(&mut self, src: Src, round: Self::Round) -> Self::Ordering; }
Assignment with a specified rounding method.
Examples
use rug::float::Round; use rug::ops::AssignRound; 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
Required Methods
fn assign_round(&mut self, src: Src, round: Self::Round) -> Self::Ordering
Peforms the assignment.
Examples
use rug::Float; use rug::float::Round; use rug::ops::AssignRound; 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<T> AssignRound<T> for (Float, Ordering) where
(&'a mut Float, &'b mut Ordering): AssignRound<T, Round = Round, Ordering = Ordering>,
[src]
(&'a mut Float, &'b mut Ordering): AssignRound<T, Round = Round, Ordering = Ordering>,
impl<T> AssignRound<T> for (Float, Float) where
(&'a mut Float, &'b mut Float): AssignRound<T, Round = Round, Ordering = (Ordering, Ordering)>,
[src]
(&'a mut Float, &'b mut Float): AssignRound<T, Round = Round, Ordering = (Ordering, Ordering)>,
impl<T> AssignRound<T> for (Complex, Complex) where
(&'a mut Complex, &'b mut Complex): AssignRound<T, Round = (Round, Round), Ordering = ((Ordering, Ordering), (Ordering, Ordering))>,
[src]
(&'a mut Complex, &'b mut Complex): AssignRound<T, Round = (Round, Round), Ordering = ((Ordering, Ordering), (Ordering, Ordering))>,
Implementors
impl AssignRound<Constant> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a Constant> for Float type Round = <Float as AssignRound<Constant>>::Round; type Ordering = <Float as AssignRound<Constant>>::Ordering;
impl AssignRound<Special> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a Special> for Float type Round = <Float as AssignRound<Special>>::Round; type Ordering = <Float as AssignRound<Special>>::Ordering;
impl AssignRound for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a Float> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a Integer> for Float type Round = Round; type Ordering = Ordering;
impl AssignRound<Integer> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a Rational> for Float type Round = Round; type Ordering = Ordering;
impl AssignRound<Rational> for Float type Round = Round; type Ordering = Ordering;
impl AssignRound<i8> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a i8> for Float type Round = <Float as AssignRound<i8>>::Round; type Ordering = <Float as AssignRound<i8>>::Ordering;
impl AssignRound<i16> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a i16> for Float type Round = <Float as AssignRound<i16>>::Round; type Ordering = <Float as AssignRound<i16>>::Ordering;
impl AssignRound<i32> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a i32> for Float type Round = <Float as AssignRound<i32>>::Round; type Ordering = <Float as AssignRound<i32>>::Ordering;
impl AssignRound<i64> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a i64> for Float type Round = <Float as AssignRound<i64>>::Round; type Ordering = <Float as AssignRound<i64>>::Ordering;
impl AssignRound<isize> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a isize> for Float type Round = <Float as AssignRound<isize>>::Round; type Ordering = <Float as AssignRound<isize>>::Ordering;
impl AssignRound<i128> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a i128> for Float type Round = <Float as AssignRound<i128>>::Round; type Ordering = <Float as AssignRound<i128>>::Ordering;
impl AssignRound<u8> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a u8> for Float type Round = <Float as AssignRound<u8>>::Round; type Ordering = <Float as AssignRound<u8>>::Ordering;
impl AssignRound<u16> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a u16> for Float type Round = <Float as AssignRound<u16>>::Round; type Ordering = <Float as AssignRound<u16>>::Ordering;
impl AssignRound<u32> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a u32> for Float type Round = <Float as AssignRound<u32>>::Round; type Ordering = <Float as AssignRound<u32>>::Ordering;
impl AssignRound<u64> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a u64> for Float type Round = <Float as AssignRound<u64>>::Round; type Ordering = <Float as AssignRound<u64>>::Ordering;
impl AssignRound<usize> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a usize> for Float type Round = <Float as AssignRound<usize>>::Round; type Ordering = <Float as AssignRound<usize>>::Ordering;
impl AssignRound<u128> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a u128> for Float type Round = <Float as AssignRound<u128>>::Round; type Ordering = <Float as AssignRound<u128>>::Ordering;
impl AssignRound<f32> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a f32> for Float type Round = <Float as AssignRound<f32>>::Round; type Ordering = <Float as AssignRound<f32>>::Ordering;
impl AssignRound<f64> for Float type Round = Round; type Ordering = Ordering;
impl<'a> AssignRound<&'a f64> for Float type Round = <Float as AssignRound<f64>>::Round; type Ordering = <Float as AssignRound<f64>>::Ordering;
impl AssignRound for Complex type Round = (Round, Round); type Ordering = (Ordering, Ordering);
impl<'a> AssignRound<&'a Complex> for Complex type Round = (Round, Round); type Ordering = (Ordering, Ordering);
impl<Re> AssignRound<Re> for Complex where
Float: AssignRound<Re, Round = Round, Ordering = Ordering>, type Round = (Round, Round); type Ordering = (Ordering, Ordering);impl<Re, Im> AssignRound<(Re, Im)> for Complex where
Float: AssignRound<Re, Round = Round, Ordering = Ordering> + AssignRound<Im, Round = Round, Ordering = Ordering>, type Round = (Round, Round); type Ordering = (Ordering, Ordering);impl<'a, Re, Im> AssignRound<&'a (Re, Im)> for Complex where
Float: AssignRound<&'a Re, Round = Round, Ordering = Ordering> + AssignRound<&'a Im, Round = Round, Ordering = Ordering>, type Round = (Round, Round); type Ordering = (Ordering, Ordering);