Hi Christopher,
if you have to make calculations or comparing operations, the only
"safe" method is to save and use only integer values.
Of course there must be a preventive agreement on the precision you
want to have (2, 3 4 ...  decimals).
The sw part is straigthforward:
- to save in the database you must multiply every float by
10**(precision)
- to use the "integers" and, for example, display them as float, you
must of course make the opposit operation (dividing).

There are drawbacks:
- the queries (from the point of view of the user) are much more
complicate
- the integer takes generally more place than the corresponding float
- the integer divide needs particular attention.

If the disk space occupied by the database is a concern, you can
evaluate the possibility to save the floats as string representation
as, for example, "1.5632"
(coming out from "%.4f" % 1.5631999999999999).

Sorry if the above considerations are not at the same level of those of
the experts, but I definitely am not an "expert". I encountered the
same problems many years ago (when the size of disks was at maximum 200
Mb).
Bye.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to