eq-float 0.1.0

Float wrappers with a total order (by setting NAN == NAN)
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 7.61 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 770.59 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • AljoschaMeyer

Eq-Float

Wrappers around rust floats that implement Eq by letting NAN == NAN be true. This lets you pretend there was a total order on floating point numbers. Use with care, this goes against the IEEE 754 standard.

Also implements Ord and Hash. The hash digest for positive and negative zero is identical, since 0.0 == -0.0. The hash digest for all NANs is also identical.

extern crate eq_float;

use eq_float::F32;

fn main() {
    assert!(!(std::f32::NAN == std::f32::NAN));
    assert!(F32(std::f32::NAN) == F32(std::f32::NAN));
    assert!(F32(std::f32::NAN) < F32(5.0));
}