2013 Archives by date, by thread · List index

# Re: [libreoffice-users] Re: Visible currency rounding

```On 07/19/2013 07:26 PM, toodr wrote:
```
```I had the same problem. I needed to implement the so called Bankers' Rounding
Function, which would round with respect to the 4/5 rule. And finally I
ended doing it myself in a short Function in LO Basic. I tried my best,
although math  and programming are not my strong sides. So here it is,
together with a Subroutine called "rounded_test" and the very Function is
called "Rounded".
```
```>
>>> A whole bunch of code stripped out here <<<
```
```

You can call it for each line (item) in an invoice. It will take the number
you through at it and will return it rounded to the second diggit after the
comma or point separator. Then when you sum the invoice up - the numbers
will always be consistent and correctly rounded.

This is not the best of programming though, but it works.
I hope it will help someone.
Feel free to modify and use it as you please.
Cheers,
toodr
```
```
```
Just one point I would like to make. If you are working with money be sure that the total of the rounded amounts adds up to match the original amount.
```
Example:

\$5.39 divided among several accounts.

10.5% to Acct A = 0.56595  => \$0.57
13.5% to Acct B = 0.72765  => \$0.73
17%   to Acct C = 0.9163   => \$0.92
59%   to Acct D = 3.1801   => \$3.18
=====
Total = \$5.40

```
Any summing error needs to be accounted for if you ever want your accounts to balance.
```

--
_
°v°
/(_)\
^ ^  Mark LaPierre
Registered Linux user No #267004
https://linuxcounter.net/
****

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
```