Hacker News new | ask | show | jobs
by pragma_x 2 days ago
> I used fixed point math which optimized well.

I feel like the idea of fixed-point is under-utilized and very under appreciated. There are loads of applications where this is a better choice, let alone more performant.

2 comments

This was the choice that Knuth made in TeX and Metafont although it’s also at least in part because floating point implementations in the late 70s/early 80s were so inconsistent from one platform to the next that using native floating point couldn’t satisfy his requirement of identical output on all platforms (likewise, the variations of Pascal implementations meant that he also used a highly restricted subset of Pascal features and no dynamic memory allocation).
> let alone more performant

Not anymore. On modern hardware, the only operation where integers win is single cycle add/sub. For the rest of operations (multiplication, division, square roots, etc.) floating point is faster, sometimes by a lot.

If you care about performance you use logs and then multiplications turn into integer additions.