Re:Beware of Fast-Math
by osigurdson on Saturday May 31, 2025 @02:14PM
(#44145986)
Good to know. In a scientific domain so haven't used it previously.
Re:Beware of Fast-Math
by MobiusHorizons on Saturday May 31, 2025 @06:29PM
(#44147374)
Fun fact there is a decimal type on some hardware. I believe Power PC, and presumably mainframes. You can actually use it from C although itβs a software implementation on most hardware. IEEE754-2008 if you are curious.
Fixed point is a general technique that is commonly done with machine integers when the necessary precision is known at compile time. It is frequently used on embedded devices that don't have a floating point unit to avoid slow software based floating point implementations. Limiting the precision to $0.01 makes sense if you only do addition or subtraction. Precision of $0.001 (Tenths of a cent also called mils) may be necessary when calculating taxes or applying other percentages although this is typically called out in the relevant laws or regulations.