Trait UncheckedSqrt

Source
pub trait UncheckedSqrt {
    // Required method
    const fn unchecked_sqrt(self) -> Self;
}
Expand description

Returns the square root of self without checking the input.

§Panics

Panics if self is negative.

Required Methods§

Source

const fn unchecked_sqrt(self) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl UncheckedSqrt for Dec19x19

§Tests

check! ( [Dec19x19::unchecked_sqrt, Dec19x19::checked_sqrt] {
    (Dec19x19!(0)) => Dec19x19!(0),
    (Dec19x19::MAX) => Dec19x19!(4_124_817_371.235_594_858_790_322_117_5),
    (-Dec19x19::SMALLEST_STEP) => FAIL,
});
// Precision test.
assert_eq!(Dec19x19!(1e-18).unchecked_sqrt() * Dec19x19!(1e-18).unchecked_sqrt(), Dec19x19!(1e-18));

§Validation

fuzzy1::<Dec19x19, BigDecimal>(Series::new(0..=19, 0..=19),
    |f1, b1| should_eq(f1.abs().unchecked_sqrt(), b1.abs().sqrt().unwrap())
);