(Apr-11-2020, 08:41 AM)DPaul Wrote: But you don't want decimals on your report (or in your accounting system for that matter).Actually I do want decimals in my accounting system, up to the last cent :-) And in some cases like interest/coupon accrual rounding is only at the end of the accrual period
int will always truncate downwards, when argument is float:
Quote:For floating point numbers, this truncates towards zero.
>>> int(5.99) 5In your example with 5.50 + 0.50 it was the same - truncated toward 6
>>> d = 5.50 + 0.50 >>> d 6.0 >>> int(d) 6
(Apr-11-2020, 08:41 AM)DPaul Wrote: "random" so to speak.Nothing random here
When working with money, better work with decimal.Decimal to avoid floating-point arithmetic surprises.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs