On Tue, Jan 8, 2019 at 3:01 PM dwight via cctalk <cctalk at classiccmp.org>
wrote:
To Tell you the truth, I can't think of anything
other than speed of
calculating that should be done in floating point. The speed is because
we've determined to waste silicon for floating point when we should really
be using combined operation in integer that are designed to handle multiple
arrays( and matices ), addition, multiplication and scaling as single
instructions.
Floating point is useful in the sciences where you are dealing with large
exponent ranges and/or need appropriate rounding.
This will make everyone groan, but somewhere around here I have a C++
template library for fixed point that tracks the result bit width position
and does scaling.
fixed<int32_t,8> a(1.0); // stored as 0x00000100
fixed<int32_t,8> b(0.5); // stored as 0x00000080
fixed<int32_t,4> c(a*b); // a*b would be fixed<int64_t,16> by default, but
multiply is overloaded for different widths
// stored as 0x00000008
Metaprogramming has its uses if you don't mind long compile times and you
understand what's going on under the hood.