Skip to main content

RoundTiesEven

Trait RoundTiesEven 

Source
pub trait RoundTiesEven: Sized {
    type Output;

    // Required method
    fn round_ties_even(self) -> Self::Output;
}
Expand description

Rounds half-way cases to the nearest even integer (banker’s rounding).

Required Associated Types§

Source

type Output

Returns the nearest integer to self, with half-way cases rounded to the even one (2.5 -> 2.0, 3.5 -> 4.0).

use const_num_traits::RoundTiesEven;

assert_eq!(RoundTiesEven::round_ties_even(2.5f32), 2.0);
assert_eq!(RoundTiesEven::round_ties_even(3.5f32), 4.0);
assert_eq!(RoundTiesEven::round_ties_even(-2.5f32), -2.0);

Required Methods§

Source

fn round_ties_even(self) -> Self::Output

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl RoundTiesEven for f32

Available on crate feature std only.
Source§

impl RoundTiesEven for f64

Available on crate feature std only.

Implementors§