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?


(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:


It is sometimes called bankers’ rounding, read about it here:

(Spencer Hunter) #4

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

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