swico / www.swiss-qr-invoice.org

Website for Swiss QR Invoice organization.
https://www.swiss-qr-invoice.org
11 stars 1 forks source link

Should amounts be rounded to cents? #24

Open epsitec opened 3 years ago

epsitec commented 3 years ago

How should amounts be rounded?

epsitec commented 3 years ago

Yes, every amount should be represented using the n.nn format. No fractional cents should be used, ever.

We suggest using round ½ away from zero as the rounding rule:

1.004 should be rounded to 1.00 1.005 should be rounded to 1.01 1.006 should be rounded to 1.01

-0.994 should be rounded to -0.99 -0.995 should be rounded to -1.00 -0.996 should be rounded to -1.00

For a discussion of various rounding methods, see https://math.stackexchange.com/questions/3448/rules-for-rounding-positive-and-negative-numbers.

epsitec commented 3 years ago

See https://github.com/swico/www.swiss-qr-invoice.org/issues/26