Trait fixnum::ops::RoundingSqrt [−][src]
pub trait RoundingSqrt: Sized {
type Error;
fn rsqrt(self, mode: RoundMode) -> Result<Self, Self::Error>;
}
Associated Types
Required methods
Checked rounding square root.
Returns Err
for negative argument.
ⓘ
use fixnum::{ArithmeticError, FixedPoint, typenum::U9};
use fixnum::ops::{Zero, RoundingSqrt, RoundMode::*};
type Amount = FixedPoint<i64, U9>;
let a: Amount = "81".parse()?;
let b: Amount = "2".parse()?;
let c: Amount = "-100".parse()?;
assert_eq!(a.rsqrt(Floor)?, "9".parse()?);
assert_eq!(b.rsqrt(Floor)?, "1.414213562".parse()?);
assert_eq!(b.rsqrt(Ceil)?, "1.414213563".parse()?);
assert_eq!(c.rsqrt(Floor), Err(ArithmeticError::DomainViolation));
Implementations on Foreign Types
Implementors
type Error = ArithmeticError
type Error = ArithmeticError
type Error = ArithmeticError
impl<P: Precision> RoundingSqrt for FixedPoint<i128, P>
This is supported on crate feature i128
only.
impl<P: Precision> RoundingSqrt for FixedPoint<i128, P>
This is supported on crate feature
i128
only.