Trait dashu_float::round::Round

source ·
pub trait Round: Copy {
    type Reverse: Round;

    // Required method
    fn round_low_part<F: FnOnce() -> Ordering>(
        integer: &IBig,
        low_sign: Sign,
        low_half_test: F
    ) -> Rounding;

    // Provided methods
    fn round_fract<const B: Word>(
        integer: &IBig,
        fract: IBig,
        precision: usize
    ) -> Rounding { ... }
    fn round_ratio(integer: &IBig, num: IBig, den: &IBig) -> Rounding { ... }
}
Expand description

A trait describing the rounding strategy

Required Associated Types§

source

type Reverse: Round

The rounding operation that rounds to an opposite direction

Required Methods§

source

fn round_low_part<F: FnOnce() -> Ordering>( integer: &IBig, low_sign: Sign, low_half_test: F ) -> Rounding

Calculate the rounding of the number (integer + rem), assuming rem != 0 and |rem| < 1. low_half_test should tell |rem|.cmp(0.5)

Provided Methods§

source

fn round_fract<const B: Word>( integer: &IBig, fract: IBig, precision: usize ) -> Rounding

Calculate the rounding of the number (integer + fract / X^precision), assuming |fract| / X^precision < 1. Return the adjustment.

source

fn round_ratio(integer: &IBig, num: IBig, den: &IBig) -> Rounding

Calculate the rounding of the number (integer + numerator / denominator), assuming |numerator / denominator| < 1. Return the adjustment.

Object Safety§

This trait is not object safe.

Implementors§