Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math.log(0) differs from math.log(0L) #38226

Closed
smontanaro opened this issue Mar 27, 2003 · 7 comments
Closed

math.log(0) differs from math.log(0L) #38226

smontanaro opened this issue Mar 27, 2003 · 7 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@smontanaro
Copy link
Contributor

BPO 711019
Nosy @tim-one, @freddrake, @smontanaro

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/smontanaro'
closed_at = <Date 2003-04-26.03:00:43.000>
created_at = <Date 2003-03-27.21:30:22.000>
labels = ['docs']
title = 'math.log(0) differs from math.log(0L)'
updated_at = <Date 2003-04-26.03:00:43.000>
user = 'https://github.com/smontanaro'

bugs.python.org fields:

activity = <Date 2003-04-26.03:00:43.000>
actor = 'skip.montanaro'
assignee = 'skip.montanaro'
closed = True
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2003-03-27.21:30:22.000>
creator = 'skip.montanaro'
dependencies = []
files = []
hgrepos = []
issue_num = 711019
keywords = []
message_count = 7.0
messages = ['15283', '15284', '15285', '15286', '15287', '15288', '15289']
nosy_count = 3.0
nosy_names = ['tim.peters', 'fdrake', 'skip.montanaro']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue711019'
versions = ['Python 2.3']

@smontanaro
Copy link
Contributor Author

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.

@smontanaro smontanaro self-assigned this Mar 27, 2003
@smontanaro smontanaro added the docs Documentation in the Doc dir label Mar 27, 2003
@smontanaro smontanaro self-assigned this Mar 27, 2003
@smontanaro smontanaro added the docs Documentation in the Doc dir label Mar 27, 2003
@smontanaro
Copy link
Contributor Author

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

@tim-one
Copy link
Member

tim-one commented Apr 25, 2003

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.

@smontanaro
Copy link
Contributor Author

Logged In: YES
user_id=44345

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

@freddrake
Copy link
Member

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.

@freddrake
Copy link
Member

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!

@smontanaro
Copy link
Contributor Author

Logged In: YES
user_id=44345

added note to Doc/lib/libmath.tex (v. 1.29 and 1.25.22.1).

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

3 participants