[Python-Dev] histerical math.log(zero)
Samuele Pedroni
pedronis at bluewin.ch
Mon Aug 4 19:45:17 EDT 2003
At 12:31 04.08.2003 -0400, Tim Peters wrote:
>[Samuele Pedroni]
> > math.log raises different unrelated exceptions depending on the type
> > of a zero argument:
>
>It may, and probably does on most platforms. Which exception gets raised
>for a float 0.0, and even whether an exception gets raised at all in that
>case, depends on what the platform libm does. Standard C allows a lot of
>variation here.
>
> > >>> math.log(0)
> >
> > Traceback (most recent call last):
> > File "<pyshell#1>", line 1, in -toplevel-
> > math.log(0)
> > OverflowError: math range error
> > >>> math.log(0L)
>
>Python handles log(long) itself, so the exception in this case is
>platform-independent.
I was asking this because I have just finished making jython handle
log(long) itself too.
And I noticed that test_long is picky about the ValueError thing.
I should have read the manual, sorry. I was more wondering that there's no
encompassing math exception.
regards.
More information about the Python-Dev
mailing list