0

There are several different methods of rounding. When developing a website that requires calculating a payment, between promotional codes, sales tax, credit card processing fees, it's possible end up with a total that results in a fraction of a penny.

What kind of rounding should be used when converting the total to two decimal places?

2
  • Round up to the next 1 cent.
    – closetnoc
    Jun 4 '14 at 23:53
  • Also calculate everything in cents. You can then skip using floats and use integers instead.
    – phoops
    Jun 5 '14 at 0:09
1

It depends on your location. The Australian department of commerce has very specific rules for rounding transactions that differ whether it is cash or credit transaction.

In the US, I find a handful of articles about rounding such as this case with Chipotle. Based on this, it does not appear that there are US laws that govern it, but that rounding could be a public relations issue if done in a way that seems unfair to consumers.

Rounding using the "nearest" rule is most widely used. When exactly half way between two values, round up (the non-scientific rounding method). This would appear to satisfy the legal requirements that I have found, as well as appearing fair to consumers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.