

Determinism with fixed point math - rasmusrn
http://www.bonsai7.dk/determinism-and-fixed-point-math.html

======
lotyrin
It's kinda poignant to think of the rediscovery of the option to -not- use a
feature.

It drives home that floating point has come to feel normal and the default
mode of doing anything and everything with a decimal point regardless of its
suitability to people's actual problems.

It reminds me of the many bugs I've fixed in web e-commerce code using floats
and accumulating rounding error with discount maths and the sad conversations
with the bug's authors afterward.

It's unfortunate more developers aren't introduced to full-featured bignums
and arbitrary precision first, that more languages don't use them by default
before offering machine numbers (and decently usable implementations of
patterns atop them like fixed precision) with their many caveats
(nondeterminism, signing, imprecision, overflows) as optimizations one can
choose -when- appropriate.

There are just so many developers (especially of business software) who are
liberally consuming memory and CPU instructions to ultimately display these
numbers with UI toolkits and constraints algorithms or HTML, CSS abstractions
etc. but accidentally refusing (through ignorance and ancient[-in-terms-of-IT]
momentum) to ever use more than the tiniest resources to actually precisely
and deterministically calculate them.

~~~
nonononyes
Yes, one should never, ever use floats to handle currency values. Since
currencies round to decimal digits, one should use decimal numbers. Databases
that store currency values have a "decimal" type too. Using integers works,
but have caveats:

[http://floating-point-gui.de/formats/integer/](http://floating-point-
gui.de/formats/integer/)

Some programming languages, like Haskell, default to Bignums (or Rationals for
numbers that aren't integers) unless you ask for something else. I think
that's a good default.

------
sago
Ah brings back memories! Nice to see old techniques rediscovered.

If the OP is reading, then please add a license to your repo. Github even nags
you about it now, but there's no excuse, even if you want to make it
proprietary.

