Hacker News new | ask | show | jobs
by jwmerrill 1639 days ago
Decimal floating point still doesn’t have associative addition or multiplication.
1 comments

But it can be shaped by rules to be associative enough to be useful for the common case. All you need to do is ensure that your calculations are in no danger of blowing past the max significant digits (much like you'd guard against overflow on integer types). Once you need more range, you switch to a multi-word numeric format (or impose rounding rules).
> All you need to do is ensure that your calculations are in no danger of blowing past the max significant digits

If you have a lot of control of the scale of the numbers you’re computing with, you could use fixed point instead of floating point.

The situations that make it useful to have a floating point (rather than fixed point) are also the situations where addition isn’t associative.

> If you have a lot of control of the scale of the numbers you’re computing with, you could use fixed point instead of floating point.

You could, but why would you go to the extra complication (and ensuing bugs) of adding an implied fixed point to integers when a decimal float type gives it to you for free?

As I said, it's not a silver bullet; it's just for the majority case (much like 32 and 64-bit integers are for the majority case when dealing with whole numbers).