safeeft 0.0.5

Safe and branchless error-free transformation algorithms for floating point numbers.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
extern crate num_traits;
extern crate float_traits;
use core::clone::Clone;
use self::num_traits::One;
use self::float_traits::{IEEE754Float, BinaryFloat};

pub trait FloatEFT: IEEE754Float + Clone {
    #[inline]
    fn split_coef() -> Self {
        let int_one = <Self as BinaryFloat>::Expo::one();
        let int_two = <Self as BinaryFloat>::Expo::one() + <Self as BinaryFloat>::Expo::one();
        Self::two_powi((Self::bits() + int_one) / int_two) + Self::one()
    }
}

impl<T: IEEE754Float + Clone> FloatEFT for T {}