Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swiss and Argentinian currency fourth decimal digit rounding

When rounding amounts of currency using the algorithm for Swiss Francs, the second and third decimal digits are considered. If less than 26, they are rounded down to 0; else if less than 76, rounded down to 5; else the whole value is rounded up.

20.125  =>  20.10
20.143  =>  20.15
20.179  =>  20.20

What happens when the amount to be rounded has a greater decimal precision? Are all decimal digits after the third simply ignored (value is truncated), or is the value first rounded in some other way to three decimal digits first? As an example, consider truncation versus a "Math.round()" approach (less than 0.5 rounds down, else round up):

Truncation                      |  "Math.round"
=================================================================
Start        3 d.p.    Rounded  |  Start        3 d.p.    Rounded
=================================================================
20.1259  ->  20.125  =>  20.10  |  20.1259  ->  20.126  =>  20.15
20.1759  ->  20.175  =>  20.15  |  20.1759  ->  20.176  =>  20.20

As the above shows, these edge cases vary a great deal in the final result.

Argentinian currency rounding follows a similar model which just concerns itself with the third decimal digit. Although the rounded result may have two or three decimal places, the same principle applies; if the value to be rounded has four or more decimal digits, should the algorithm just truncate anything after the third digit or should it apply some other kind of intermediate rounding to get a three decimal place result first?

Thanks!

like image 279
Andrew Hodgkinson Avatar asked Feb 27 '11 16:02

Andrew Hodgkinson


People also ask

How do you round off currency?

Round down for a dollar amount that has 0 to 49 cents. For example, $89.27 rounds down to $89. Round up for dollar amounts that have 50 to 99 cents. For example, $53.52 rounds up to $54.

Do you round up with currency?

Always rounded down. Rounding is done to the nearest 5 cents. 1 and 5 won coins are no longer in general use and prices are rounded to the nearest 10 won when paying with cash.

Should money always be rounded up?

Financial values are usually rounded to a decimal number with fewer decimal places, or to a specific interval (such as the nearest 10, 100, or 1 million). If the next interval or decimal place is 1-4, the number should be rounded down, if it's 5-9, it should be rounded up.

Does money always round down?

When rounding, remember if its five or more, you round up. Anything else, you round down. Determine if you want to round to the nearest dollar or the nearest penny.


1 Answers

If less than 26, they are rounded down to 0; else if less than 76, rounded down to 5; else the whole value is rounded up.

By this I would assume the "Truncation" method would be appropriate, since 0.0259XXXXX is less than 0.026

like image 154
lesscode Avatar answered Oct 07 '22 11:10

lesscode