float_next_after 0.1.1

A trait for native rust f64/f32 nextafter
Documentation

float_next_after

A native Rust next after float function, which is provided as a trait for f32 and f64 types.

I am neither a mathemetician, nor an expert in floating point number representations, so I am uncertain if this algorithm is absolutely correct. Please see the tests for the behavior in several cases. It does indeed provide numbers a very small distance away from the current float, but I am unsure with numbers very close to 0 if this algorithm really present the absolute next representable f32/f64 in a certain direction, rather than just another representable float a very small distance away.

PR's and other helpful input greatly welcome.

Usage

use float_next_after::NextAfter;

let big_num = 16237485966.00000437586943_f64;
let next = big_num.next_after(&std::f64::INFINITY);
assert_eq!(next, 16237485966.000006_f64);

let zero = 0_f64;
let next = zero.next_after(&std::f64::NEG_INFINITY);
assert_eq!(next, -0.0000000000000002220446049250313);