[Tutor] Help on float & round.

Magnus Lyckå magnus@thinkware.se
Wed Jun 11 12:45:02 2003


At 09:33 2003-06-11 -0500, Decibels wrote:
>Bookmarked. Thanks.
>While on the subject of float and round. I originally tried to make it
>save the value as, 'rounded', to save it in a database.
>That doesn't seem to work and I don't think there is a way to do so.
>For accuracy sake it makes sense, just wondering if there was a way.

In Python, any floating point number is stored as a
Double Precision Floating Point. i.e. "double" in the
underlying C language library. Typically 8 bytes.

1.2 won't use more space than 1.21212121212121

What do you mean by database in this case?

SQL databases typically have data types where
you can define how many decimals they should
store. The database adapter will take care of
conversion between Pythons float format and
the format defined for the database.


--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language