2013 Archives by date, by thread · List index

# [libreoffice-users] Re: Visible currency rounding

```You described it in the most precise way.
I needed a function that would round down the number if the followin digit
is less then 5,
and would round up if the followin digit is greater then 5,
and if the followin digit is equal to 5 then it will test if the last digit
to remain in the number is odd or even and then round it up if it is odd or
leave as it is if it is even.
I think this is called "Round half to even" as a "tie braking rule".

But even more accurate description is here:
http://www.xbeat.net/vbspeed/i_BankersRounding.htm

I must confess I did not have an idea that this was called "Gaussian
rounding".

In my case the function needs to start from the least available right
standing digit for the given number and round consecutively from there to
the left untill the desired digit position is reached, one digit at a time .
This way it ensures that any boundary cases be treated correctly.
The practical need for this is when I had to fill in an invoice, on each row
I wold have an intermediate number which is a result of multiplication of
amount by unit price (i.e. an item's sum), which in the general case will
not be an exact number . Then I would need to round this number to a
sensible (currency) format and only then to add the numbers up in order to
get the final amount for the invoice. In this way all numbers add up
correctly and there is no difference in the final amount.

As for the example where 23,574 rounds to 23,57 , this is the intended
result as described above.
Thanks again for the clarification you've given in your post.

Regards,
toodr

--
View this message in context:
http://nabble.documentfoundation.org/Visible-currency-rounding-tp4065342p4066383.html
Sent from the Users mailing list archive at Nabble.com.

--
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
```