floor() function and mathematical integers
Aahz Maruch
aahz at panix.com
Wed May 30 19:19:11 EDT 2001
In article <mailman.990829418.15526.python-list at python.org>,
Tim Peters <tim.one at home.com> wrote:
>[Aahz Maruch]
>> ...
>> For comparison, take a look at this routine from Tim Peters to convert
>> floats to strings (yes, Tim, I modified it to work with 1.5.2):
>>
>> ....
>> return "%s%de%d" % (sign, top, e)
>
>They're you're in trouble in 1.5.2: top can be a large integer indeed, and
>1.5.2 can't convert an unbounded int via %d. You would have discovered that
>had you tested it <wink>. Try this instead:
<sigh> The version of doctest that I'm currently using only works under
2.x, so my 1.5.2 testing has been largely ad hoc. I can't wait for
Cowlishaw to release his platform-neutral test cases.
> return "%s%se%d" % (sign, repr(top)[:-1], e)
>
>The "-1" slicing is to get rid of the trailing "L".
Yeah, I know that one. It's in other places in my code, given that I'm
using longs for exponents, and it's also in the long conversion routine.
--
--- Aahz <*> (Copyright 2001 by aahz at pobox.com)
Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
"Characters exist to suffer, you know. An author needs a little sadism
in her makeup." --Brenda Clough
More information about the Python-list
mailing list