Discussion:
Bug in dc
(too old to reply)
Russell Harper
2018-07-17 19:28:46 UTC
Permalink
Literal real values in bases other than 10 lose precision, e.g.

$ dc <<<'16 d i o F423F.FD p'
F423F.FA

Would expect the output to be F423F.FD

It basically makes the calculator useless for non-decimal calculations.

Regards,

Russell
John Cowan
2018-07-17 20:23:00 UTC
Permalink
That's because bc uses base-10 arithmetic internally. It is the equal and
opposite phenomenon to the loss of significance in other languages when
using standard base-2 floating point.
Post by Russell Harper
Literal real values in bases other than 10 lose precision, e.g.
$ dc <<<'16 d i o F423F.FD p'
F423F.FA
Would expect the output to be F423F.FD
It basically makes the calculator useless for non-decimal calculations.
Regards,
Russell
Continue reading on narkive:
Loading...