4 releases

0.0.7 Oct 15, 2023
0.0.6 Oct 14, 2023

#1454 in Math

Download history 9/week @ 2024-07-22 47/week @ 2024-07-29 23/week @ 2024-08-05 21/week @ 2024-08-12 5/week @ 2024-08-19 28/week @ 2024-08-26 22/week @ 2024-09-02 28/week @ 2024-09-09 25/week @ 2024-09-16 68/week @ 2024-09-23 31/week @ 2024-09-30 2/week @ 2024-10-07 14/week @ 2024-10-14 20/week @ 2024-10-21 17/week @ 2024-10-28 22/week @ 2024-11-04

73 downloads per month
Used in 7 crates (4 directly)

MIT license

23KB
520 lines

umath: ffast-math, for rust.

MSRV DOCS

Want to make your math faster? *t&c apply

Want to order a float?

You can do all of that, with umath!

use umath::FFloat;
// wrap a non NAN and non INF f32/f64 (we will also *never* make this number nan).
let mut f = unsafe { FFloat::new(4.0f32) };
f *= 3; // multiply by 3
// this check will be removed by the optimizer!
assert!(!f.is_nan());
# use std::collections::BinaryHeap;
// use a ORD type! this is allowed, as FFloat is not allowed to be NAN | INF.
let mut b = BinaryHeap::new();
b.push(unsafe { FFloat::new(2.0) });
b.push(unsafe { FFloat::new(1.0) });
b.push(unsafe { FFloat::new(3.0) });
b.push(f);
assert_eq!(b.pop(), Some(unsafe { FFloat::new(24.0) }));

A note on safety

When you make your first FFLoat, you must promise that you will never create a NAN | INF FFLoat. Hence, *f = NAN is (delayed) UB.

Nightlyness

umath is nightly because it makes use of core intrinsics, like fadd_fast(), which require the core_intrinsics feature to use.

No runtime deps