logoalt Hacker News

librasteve • today at 8:15 AM • 2 replies • view on HN

Having witnessed the acceleration and adoption of IEEE754 close up (Weitek in the 80s), it is easy to underestimate the level of hardware tuning tricks baked into and developed around that standard.

I have made a spreadsheet app in Rust with exact and fast arithmetic, centered on Apache Arrow and Polars, so Integer (i64) and Float (f64) are joined by Decimal[n] (.parquet Decimal38) and Fraction(num/dec).

After considering some alternatives for Fraction, including BigRat and maybe interval arithmetic the current pick is symbolic handling of num/dec stored as .parquet Strings. Why? Well the other three types are fast, so it seems OK to have a slow but sure “back stop”.

It works well for Googol ranges of arithmetic and knows that 1/7+4/7 is 5/7. This seems good for teaching purposes and scratching the exactness itch.

Anyway, I’m open to adding Posit provided there’s a Rust crate (fast-posit.rs?) and a way to shoe horn them into parquet. Please raise an issue over at https://omasheet.org repo if this is of interest.


Replies

gregates • today at 8:43 AM

Funny thing about spreadsheets is that, if you want to be Excel-compatible, IEEE 754 isn't sufficient. Excel worries a lot about making floating point numbers feel like real numbers to non computer scientists, to the extent that it sacrifices precision to achieve the property that the digits you type might by truncated, but they'll never be rounded to a non-zero digit. And many Excel features work on numbers as displayed, rather than the underlying bytes. Numeric identity isn't bit-equivalence, in Excel. And order isn't even transitive, for some applications (like filters).

It's very easy to make a spreadsheet that adds binary64 numbers faster than Excel.

andrepd • today at 9:22 AM

I'm the maintainer of fast-posit. It is not "feature complete" in the sense that it doesn't implement all those elementary functions prescribed by the standard, with 100% correct rounding (far beyond my powers :)). It does impl the four basic operations, sqrt, conversions between it and all fundamental Rust numeric types, comparisons, all quire operations (add, sub, dot product): everything correctly rounded, and tested exhaustively or with proptest. It also supports "bounded-posits" (one more parameter you tweak to make sure your type covers your expected domain accurately).

I'm not sure how relevant it is to you, since you require exact arithmetic! In fact I'm not sure how you even use floats at all.