[−][src]Trait rug::ops::AssignRound
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
Loading content...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);
Implementors
impl AssignRound<Constant> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: Constant, round: Round) -> Ordering
[src]
impl AssignRound<Special> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: Special, _round: Round) -> Ordering
[src]
impl AssignRound<f32> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: f32, round: Round) -> Ordering
[src]
impl AssignRound<f64> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: f64, round: Round) -> Ordering
[src]
impl AssignRound<i128> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: i128, round: Round) -> Ordering
[src]
impl AssignRound<i16> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: i16, round: Round) -> Ordering
[src]
impl AssignRound<i32> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: i32, round: Round) -> Ordering
[src]
impl AssignRound<i64> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: i64, round: Round) -> Ordering
[src]
impl AssignRound<i8> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: i8, round: Round) -> Ordering
[src]
impl AssignRound<isize> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: isize, round: Round) -> Ordering
[src]
impl AssignRound<u128> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: u128, round: Round) -> Ordering
[src]
impl AssignRound<u16> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: u16, round: Round) -> Ordering
[src]
impl AssignRound<u32> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: u32, round: Round) -> Ordering
[src]
impl AssignRound<u64> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: u64, round: Round) -> Ordering
[src]
impl AssignRound<u8> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: u8, round: Round) -> Ordering
[src]
impl AssignRound<usize> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: usize, round: Round) -> Ordering
[src]
impl AssignRound<Complex> for Complex
[src]
type Round = (Round, Round)
type Ordering = (Ordering, Ordering)
fn assign_round(
&mut self,
src: Complex,
round: (Round, Round)
) -> (Ordering, Ordering)
[src]
&mut self,
src: Complex,
round: (Round, Round)
) -> (Ordering, Ordering)
impl AssignRound<Float> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: Float, round: Round) -> Ordering
[src]
impl AssignRound<Integer> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: Integer, round: Round) -> Ordering
[src]
impl AssignRound<Rational> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: Rational, round: Round) -> Ordering
[src]
impl<'_> AssignRound<&'_ Constant> for Float
[src]
type Round = <Float as AssignRound<Constant>>::Round
type Ordering = <Float as AssignRound<Constant>>::Ordering
fn assign_round(&mut self, src: &Constant, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ Special> for Float
[src]
type Round = <Float as AssignRound<Special>>::Round
type Ordering = <Float as AssignRound<Special>>::Ordering
fn assign_round(&mut self, src: &Special, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ f32> for Float
[src]
type Round = <Float as AssignRound<f32>>::Round
type Ordering = <Float as AssignRound<f32>>::Ordering
fn assign_round(&mut self, src: &f32, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ f64> for Float
[src]
type Round = <Float as AssignRound<f64>>::Round
type Ordering = <Float as AssignRound<f64>>::Ordering
fn assign_round(&mut self, src: &f64, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ i128> for Float
[src]
type Round = <Float as AssignRound<i128>>::Round
type Ordering = <Float as AssignRound<i128>>::Ordering
fn assign_round(&mut self, src: &i128, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ i16> for Float
[src]
type Round = <Float as AssignRound<i16>>::Round
type Ordering = <Float as AssignRound<i16>>::Ordering
fn assign_round(&mut self, src: &i16, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ i32> for Float
[src]
type Round = <Float as AssignRound<i32>>::Round
type Ordering = <Float as AssignRound<i32>>::Ordering
fn assign_round(&mut self, src: &i32, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ i64> for Float
[src]
type Round = <Float as AssignRound<i64>>::Round
type Ordering = <Float as AssignRound<i64>>::Ordering
fn assign_round(&mut self, src: &i64, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ i8> for Float
[src]
type Round = <Float as AssignRound<i8>>::Round
type Ordering = <Float as AssignRound<i8>>::Ordering
fn assign_round(&mut self, src: &i8, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ isize> for Float
[src]
type Round = <Float as AssignRound<isize>>::Round
type Ordering = <Float as AssignRound<isize>>::Ordering
fn assign_round(&mut self, src: &isize, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ u128> for Float
[src]
type Round = <Float as AssignRound<u128>>::Round
type Ordering = <Float as AssignRound<u128>>::Ordering
fn assign_round(&mut self, src: &u128, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ u16> for Float
[src]
type Round = <Float as AssignRound<u16>>::Round
type Ordering = <Float as AssignRound<u16>>::Ordering
fn assign_round(&mut self, src: &u16, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ u32> for Float
[src]
type Round = <Float as AssignRound<u32>>::Round
type Ordering = <Float as AssignRound<u32>>::Ordering
fn assign_round(&mut self, src: &u32, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ u64> for Float
[src]
type Round = <Float as AssignRound<u64>>::Round
type Ordering = <Float as AssignRound<u64>>::Ordering
fn assign_round(&mut self, src: &u64, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ u8> for Float
[src]
type Round = <Float as AssignRound<u8>>::Round
type Ordering = <Float as AssignRound<u8>>::Ordering
fn assign_round(&mut self, src: &u8, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ usize> for Float
[src]
type Round = <Float as AssignRound<usize>>::Round
type Ordering = <Float as AssignRound<usize>>::Ordering
fn assign_round(&mut self, src: &usize, round: Self::Round) -> Self::Ordering
[src]
impl<'_> AssignRound<&'_ Complex> for Complex
[src]
type Round = (Round, Round)
type Ordering = (Ordering, Ordering)
fn assign_round(
&mut self,
src: &Complex,
round: (Round, Round)
) -> (Ordering, Ordering)
[src]
&mut self,
src: &Complex,
round: (Round, Round)
) -> (Ordering, Ordering)
impl<'_> AssignRound<&'_ Float> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: &Float, round: Round) -> Ordering
[src]
impl<'_> AssignRound<&'_ Integer> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: &Integer, round: Round) -> Ordering
[src]
impl<'_> AssignRound<&'_ Rational> for Float
[src]
type Round = Round
type Ordering = Ordering
fn assign_round(&mut self, src: &Rational, round: Round) -> Ordering
[src]
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>,
[src]
Float: AssignRound<&'a Re, Round = Round, Ordering = Ordering> + AssignRound<&'a Im, Round = Round, Ordering = Ordering>,
type Round = (Round, Round)
type Ordering = (Ordering, Ordering)
fn assign_round(
&mut self,
src: &'a (Re, Im),
round: (Round, Round)
) -> (Ordering, Ordering)
[src]
&mut self,
src: &'a (Re, Im),
round: (Round, Round)
) -> (Ordering, Ordering)
impl<Re> AssignRound<Re> for Complex where
Float: AssignRound<Re, Round = Round, Ordering = Ordering>,
[src]
Float: AssignRound<Re, Round = Round, Ordering = Ordering>,
type Round = (Round, Round)
type Ordering = (Ordering, Ordering)
fn assign_round(
&mut self,
src: Re,
round: (Round, Round)
) -> (Ordering, Ordering)
[src]
&mut self,
src: Re,
round: (Round, Round)
) -> (Ordering, Ordering)
impl<Re, Im> AssignRound<(Re, Im)> for Complex where
Float: AssignRound<Re, Round = Round, Ordering = Ordering> + AssignRound<Im, Round = Round, Ordering = Ordering>,
[src]
Float: AssignRound<Re, Round = Round, Ordering = Ordering> + AssignRound<Im, Round = Round, Ordering = Ordering>,