August 13, 2015 at 2:28 am
I tend to prefer working in the sub unit i.e. pence or cents rather than pounds, dollars or Euros. That way I can stick to integer arithmetic.
Where apportionment is required divide for all except the final installment and then correct for the rounding errors in the final one.
If you need to consider currency conversions you are going to need to worry about precision - do all your calculations on your base currency then convert the results - this will minimise the overall error. Point this out to the users if you need to display converted values for individual items as well as the total as they may not appear to add up in a different currency.
August 13, 2015 at 7:18 am
Where apportionment is required divide for all except the final installment and then correct for the rounding errors in the final one.
I don't understand what this means. Please clarify.
August 17, 2015 at 7:23 am
RonKyle (8/13/2015)
I don't understand what this means. Please clarify.
If you want to split the payment into installments - divide the total + any premium by the number of installments. Use the value this generates for all except the last installment. For the last one multiply the calculated installment amount by the number of installments -1 and then subtract that from the total - that gives the amount for the final installment. That way you charge the correct amount overall but the last installment may be different from the others.
August 17, 2015 at 7:55 am
Thanks for the clarification.
August 17, 2015 at 8:23 am
Sean Lange (8/11/2015)
RonKyle (8/11/2015)
If you're going to use the decimal data type, you should probably go to 4 decimal places. There is rounding that needs to take place behind the scenes. I have a vague memory this is some kind of standard, but can't swear to that anymore without some research.When you have to perform division it will round which is why often times financial applications go to 4 decimal places. This often happens when calculating interest.
I have to tell you that for calculating things like amortization tables, 4 decimal places is simply not enough. 15 seems to be the magic number. And, yes, Granny Spreadsheet will catch the penny errors produced by 4 decimal places, raise hell, and prop it up on a stick. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
August 17, 2015 at 8:36 am
I have to tell you that for calculating things like amortization tables, 4 decimal places is simply not enough. 15 seems to be the magic number. And, yes, Granny Spreadsheet will catch the penny errors produced by 4 decimal places, raise hell, and prop it up on a stick.
I can see that. I remember back when I was teaching applications and was experimenting with all the three main spreadsheets, only Lotus 1-2-3 calculated my mortgage in a way that matched the bank. MS Excel was the least accurate as I recall. Can't remember the name of third spreadsheet program. You would think that there would be an accepted standard when dealing with this type of calculation rather than have everyone all over the map.
Viewing 6 posts - 16 through 20 (of 20 total)
You must be logged in to reply to this topic. Login to reply