[Python-bugs-list] [ python-Bugs-711019 ] math.log(0) differs from math.log(0L)

SourceForge.net noreply@sourceforge.net
Fri, 25 Apr 2003 14:22:41 -0700


Bugs item #711019, was opened at 2003-03-27 16:30
Message generated for change (Comment added) made by fdrake
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=711019&group_id=5470

Category: Documentation
Group: Python 2.3
Status: Open
Resolution: Wont Fix
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Skip Montanaro (montanaro)
Summary: math.log(0) differs from math.log(0L)

Initial Comment:
This is maybe a minor nit, but math.log(0) raises an OverflowError
(range error) while math.log(0L) raises a ValueError (domain error).
Seems to me they ought to behave the same.  I noticed this in
2.2.2 but it's present in CVS.  In 2.1, both return -Inf.


----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-04-25 17:22

Message:
Logged In: YES 
user_id=3066

I'll also note that the patch should be applied for 2.2.3;
there's no need to delay committing it on that branch.

Thanks, Skip!

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2003-04-25 17:21

Message:
Logged In: YES 
user_id=3066

Reopened and assigned to Skip for a documentation patch he
has.  It will be applied *after* the 2.3b1 release; we're
too far along at this point.

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2003-04-25 17:15

Message:
Logged In: YES 
user_id=44345

Thanks, I'll see about getting a blurb added to the math module docs.


----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2003-04-25 16:09

Message:
Logged In: YES 
user_id=31435

I'm happy enough the way it is.

2.2 specifically added the ability to get a good result for log
(long) even when the long is far too large to fit in a float.  
That's why log(long) takes a different path starting in 2.2, and 
why there's no inconsistency across platforms in log(0L) 
behavior since 2.2.

If you want consistency for log(0.0), then Python cannot allow 
the platfrom log to see 0.0:  "standard" libm error behavior is 
platform-dependent, and error cases for log aren't unique in 
this respect:  Python would have to write its own error-
checking code around all libm functions.  That's a much 
larger project than it may sound, and short of doing that, 
there's really no point special-casing the snot out of one 
specific log case.

It might be better if the math module docs explained that the 
specific exceptions raised in assorted error cases (and even 
whether some arguments are considered to be exceptional at 
all) are, in reality, not defined in any useful cross-platform or 
cross-release way.

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2003-03-28 17:50

Message:
Logged In: YES 
user_id=44345

Ack!  I realized this is probably platform-dependent.  The results I
reported on were for Mac OS X.  Here's a little table of everything I could
quickly get my hands on.

Platform                Python Version  math.log(0)     math.log(0L)
Mac OS X                2.1.3           -Inf            -Inf
Mac OS X                2.2.2           OverflowError   ValueError
Mac OS X                CVS             OverflowError   ValueError
Win2k/MSVC              2.2.2           OverflowError   ValueError
Win2k/MSVC              2.3a2           OverflowError   ValueError
Win2k/cygwin            2.2.2           ValueError      ValueError
Solaris/gcc 2.95.2      2.3a2+          OverflowError   ValueError

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=711019&group_id=5470