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?

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

1 Answer 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 and acknowledge you have read our privacy policy.

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