HELP: restore my faith in Python

Andrew Henshaw andrew.henshaw at gtri.gatech.edu
Wed Mar 8 03:22:19 EST 2000


Tim Peters wrote:
>[Ken Seehof]
>> Seems to me an improvement would be to have python artificially
>> add epsilon to floats before converting to int.  This would still
>> suck but IMHO it would suck less.
>
>In my arrogant option, it's a terrible idea.  You're welcome <wink>.

In Occam (the other white-space language), you are required to specify
'TRUNC' or 'ROUND' as an additional parameter when doing a float to int
conversion. 

Surprisingly, you are also forced to specify 'TRUNC' or 'ROUND'
when making an int to float conversion.  The reasoning is that an IEEE
single-precision float doesn't have as many mantissa bits as a 32-bit int and
something could be lost in the conversion (Occam is very good at making the
programmer specify side effects).  I believe that you are also required to
make the specfication when converting to a double-precision float, but then
it would be simply for consistency.

Andrew Henshaw



More information about the Python-list mailing list