openerp-expert-framework team mailing list archive
-
openerp-expert-framework team
-
Mailing list archive
-
Message #00482
Re: rounding - float errors - various issues with "0.0"
Ferdinand Gassauer [via openerp-expert-framework] escribió:
Hi all!
We have learned in various discussion that using float in python will
not couse rounding problems.
Nevertheless it causes already problems with
* filters ( "equal 0" and "not equal 0") (see Bug 654861
<https://bugs.launchpad.net/bugs/654861> )
* internal checks (see Bug 656378
<https://bugs.launchpad.net/bugs/656378> )
These issues are very unpleasant because WYSIWYG is broken. It
undermines the confidence in OpenERP
So please make sure that coding handles this correctly
The equality tests should be made with care when working with floating
point numbers.
The easiest example on Python:
>>> 1.1 - 1 == 0.1
False
>>> round(1.1 - 1, 4) == round(0.1, 4)
True
>>> 1.1 - 1 - 0.1 == 0
False
>>> 1.1 - 1 - 0.1
8.3266726846886741e-17 /# Almost 0, but not exactly 0!/
As you can see, even the simplest operation might cause problems if not
propertly handled!
Regards.
--
Borja López Soilán
borjals@xxxxxxxxx
Pexego Sistemas Informáticos S.L.
Avenida de Magoi 66 - 27002 Lugo (España)
Tel./Fax 982801517
http://www.pexego.es
AVISO LEGAL - CLÁUSULA DE PRIVACIDAD
Este mensaje se dirige exclusivamente a su destinatario y puede contener información privilegiada o confidencial. Si no es usted el destinatario indicado, queda informado de que la utilización, divulgación y/o copia sin autorización está prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
References