6 ms·
As far as I can tell this point about the benefits of fixed point is very confused. The difference here is entirely because they use fixed point numbers with hi
by topaz0 4y ago
As far as I can tell this point about the benefits of fixed point is very confused. The difference here is entirely because they use fixed point numbers with higher precision than the precision of standard floats. You could get the same benefit with higher-precision floats (and then also be able to represent large or small numbers). So this has nothing to do with the merits of different ways of storing your numbers. I have nothing against fixed point where appropriate, but this is not a good argument.
Besides, they show at the end that increasing the precision doesn't solve the problem, just delays it.
"A better implementation will require careful use of the Decimal package in Python."
No: a better implementation requires careful analysis of why/when rounding becomes a problem, and designing your algorithm to mitigate that.
EDIT: I just had a glance at the decimal library in python and it looks like this python "fixed point" implementation doesn't even use fixed point: it's just a decimal float. (Though correct me if I'm wrong).
- GartzenDeHaes 4y agoIt's not actually fixed point. All data in COBOL is text based, including numbers[1]. When number are put into working storage fields, they are converted to text and have to be truncated to the length of the field in characters. [1] The COMP keyword does not convert working storage to binary, BTW.
- topaz0 4y agoI get what you're saying about the representation, but I think it's fair to say COBOL numbers are stored as decimal fixed point. i.e. it stores a certain number of digits, and the least-significant digit always has the same place value. (Though, again, correct me if I'm wrong).
- kragen 4y agothe reason you want to use decimal arithmetic is not so that your rounding will be more correct, but so that it will be rounded off in the same way as your bank and your auditors round off; it would be very unfortunate if there was a one-penny discrepancy in half of a million transactions per day, especially if for some statistical reason there's a bias in that discrepancy
- topaz0 4y agoAbsolutely there are reasons to choose to do your rounding in a particular way for a particular purpose. I was only making the point that the argument for using fixed point decimal that is laid out in the post had nothing to do with the choice of decimal and nothing to do with the choice of fixed point.
- kragen 4y agoi wasn't trying to defend the post