Comment 12 for bug 882036

Revision history for this message
Cloves Almeida (cjalmeida) wrote : Re: [Bug 882036] Re: rounding error

This functions seems to do the trick. Simply a add 1 (or -1) to account for
-1<x<1 numbers.

def roundf(f, prec=0):
    sig = cmp(f,0)
    factor = pow(10,prec)
    return round((f + sig) * factor - factor*sig) / factor

On Wed, Nov 16, 2011 at 1:55 PM, Lorenzo Battistini - Agile BG - Domsense <
<email address hidden>> wrote:

> See https://bugs.launchpad.net/openobject-addons/+bug/865387/comments/5
>
> --
> You received this bug notification because you are a member of OpenERP
> Framework Experts, which is subscribed to OpenERP Server.
> https://bugs.launchpad.net/bugs/882036
>
> Title:
> rounding error
>
> Status in OpenERP Server:
> New
>
> Bug description:
> Concerns 6.0 and trunk.
> If you define a precision of 0.01, the rounding of 0.125 must be 0.13 and
> not 0.12. The error is in the call of the format string "%.2f"%val which
> introduces a mathematical error. The round function must be called to apply
> the correct rounding before formatting the string. It should be:
> "%.2f"%round(val*100)/100
> Fix class digits_change of class float in the server. BUT fix also the
> gtk client AND web client as they all have that error (I let you find the
> right line)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-server/+bug/882036/+subscriptions
>