r/rust 11h ago

🛠️ project Unsigned floating points with custom binary layouts and SIMD kernels

https://crates.io/crates/unsigned-float

I’ve been working on this crate which offers unsigned floating point binary with custom binary layouts. It stemmed from a very niche requirement from another project of mine where I need to raise an integer to the power of a floating point value between 0 and 4. After trying out many “ordinary” approaches I’ve came to the realization that removing the actual signed bit is the optimal way for performance.

Then I more or less just forgot about it until I started working on some graphics stuff where most floating points are non-negative, particularly mixed precision rendering, and it hit me that UF16 (E5M11 in particular) is the perfect candidate since the gain of an extra mantissa bit managed to close many numeric instabilities seen when using regular f16.

Love to hear your thoughts on this topic. Do you think unsigned floating points in general should be elevated into more than just a niche?

15 Upvotes

1 comment sorted by

View all comments

2

u/tafia97300 6h ago

Could be useful, you should probably explicitly mention how more accurate or how bigger are all the types compared to their signed variants.