psykiatris / interestcalc

An IntelliJ project with simple classes to calculate interest on savings and credit card accounts.
0 stars 0 forks source link

Dealing with franctional months #3

Open psykiatris opened 4 years ago

psykiatris commented 4 years ago

I need to find a solution. If I only want to show one month of interest, the fractional part is imporant to obtain the right calculation. On my old laptop, the code worked when I put in the result of diving 1 into 12, which is 0.0833333337; on my new Dell desktop, this displays more than one month and returns info for two. I had to enter .083, and this properly shows. So, it's rounding up on one system (using an AMD processor), while it rounds down on a system with an Intel processor.

To solve this, I may have to force it to round down in all cases, so that it can display properly.

Am I wrong, or how should I take care of the precision so that it can work across all system architectures?

psykiatris commented 4 years ago

I was wrong. The result is .083333333. It shouldn't round up. So, it works. But, it could be improved.