How exactly you round .5% of the amount to charge the fee (in a programming language general way)


(PK) #1

I am still troubled to record/quote exact fees in my application. I thought I had figured it out that you round down but I was bitten again today. For instance here is what I have seen:

.005 * $125 = .625 you charge 62 cents fee but
.005 * $27 = 0.135, then you charge 14c fee

Can you please provide the exact algorithm?

Thanks


(Travis Dangel) #2

I think the method you’re describing or seeking is called ‘banker’s rounding’ or ‘rounding to half even’ which means you round to the nearest even number when rounding decimals ending in a trailing 5.

See here for more discussion on and reasoning behind this method:


#3

It is sometimes called bankers’ rounding, read about it here: https://en.wikipedia.org/wiki/Rounding#Round_half_to_even


(Spencer Hunter) #4

@bmarket is correct, It’s bankers rounding. Basically if it’s split, it rounds to the even number.

http://wiki.c2.com/?BankersRounding
https://msdn.microsoft.com/en-us/library/system.midpointrounding(v=vs.110).aspx

Let us know if there’s any additional information we can provide!