Its being printed to too high a precision. If you reduce the precision by one digit, then it becomes 0.3000000000000000 and the trailing zeros are then discarded leaving 0.3. I don't think the random digits at the end have any meaning - but I may be wrong!I don't have a problem with that. The issue IMO comes down to whether str(0.1 + 0.2) should deliver a "0.30000000000000004" or "0.3" result. I believe it should be the first. The first is an accurate representation of what value it actually held, while "0.3" is not.
Code:
>> 0.1 + 0.20.3>> np 25 0.300000000000000044408921>> np 180.300000000000000044>> np 170.30000000000000004>> np 160.3>>Use decimal arithmetic instead of binary if you need accurate results for things like 0.1 + 0.2
_Decimal64 or _Decimal32 in C.
This is important for currency stuff.
Statistics: Posted by jahboater — Mon Apr 28, 2025 9:10 pm