OSCommerce Product Manager for Windows
FS#264 - Rounding errors using floating-point variables.
Attached to Project:
OSCommerce Product Manager
Opened by Mario A. Valdez-Ramirez (mvaldez) - Wednesday, 07 September 2005, 14:05 GMT
Last edited by Mario A. Valdez-Ramirez (mvaldez) - Sunday, 11 September 2005, 05:09 GMT
Opened by Mario A. Valdez-Ramirez (mvaldez) - Wednesday, 07 September 2005, 14:05 GMT
Last edited by Mario A. Valdez-Ramirez (mvaldez) - Sunday, 11 September 2005, 05:09 GMT
|
DetailsAt several places in the source-code, we are using double/real variables (floating-point). Because they are rounded when being displayed and when entered in the database, we are not noticing rounding-errors.
However, while writting the Currency Management funtions, we saw lot of rounding errors. The ultimate cause is that the table Currencies of osCommerce is using a FLOAT field type for the currency value (the product prices, taxes and other data is being stored as DECIMAL). All usage of DOUBLE/REAL variables in the client-side (Delphi code) should be replaced by fixed-point variables (CURRENCY). We already do for most operations, but we need to do it everywhere. |
This task depends upon
Closed by Mario A. Valdez-Ramirez (mvaldez)
Sunday, 11 September 2005, 05:09 GMT
Reason for closing:
Sunday, 11 September 2005, 05:09 GMT
Reason for closing:
Fixed. Closing.
There is one item which still has rounding error but at the database: the currency value (as explained before). We try to minimize the problem by assigning currency-rounded (four decimal places) values to it.