Crates.io | umath |
lib.rs | umath |
version | 0.0.7 |
source | src |
created_at | 2023-10-03 02:35:14.840734 |
updated_at | 2023-10-15 01:13:25.232722 |
description | ffast-math in rust |
homepage | |
repository | https://github.com/bend-n/umath |
max_upload_size | |
id | 990687 |
size | 24,694 |
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) }));
When you make your first FFLoat
, you must promise that you will never create a NAN
| INF
FFLoat
. Hence, *f = NAN
is (delayed) UB.
umath
is nightly because it makes use of core intrinsics, like fadd_fast()
, which require the core_intrinsics
feature to use.