-
-
Notifications
You must be signed in to change notification settings - Fork 32k
log(Decimal(x)) is broken for large x #106502
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
Comments
The >>> import decimal
>>> x = decimal.Decimal(300**300)
>>> x.ln()
Decimal('1711.134742396860317829368444') |
Actually >>> float(decimal.Decimal(300**300))
inf |
You should not rely on |
I understand all of that. What I am asking is following: Does documentation/specification states this restrictions? |
There is another issue with float() implementation . From: https://docs.python.org/3/library/functions.html?#float
According to this OverflowError should be raised from |
That's only true for
You should look at the following paragraph for general Python objects.
|
On one hand, it might be considered as a tiny documentation issue for the Here is a patch.diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 3520609706..2672d243c7 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -677,7 +677,7 @@ are always available. They are listed here in alphabetical order.
Otherwise, if the argument is an integer or a floating point number, a
floating point number with the same value (within Python's floating point
- precision) is returned. If the argument is outside the range of a Python
+ precision) is returned. If an integer is outside the range of a Python
float, an :exc:`OverflowError` will be raised.
For a general Python object ``x``, ``float(x)`` delegates to
On another hand, there could be some confusion in this case: >>> log(int(d))
1711.1347423968602
>>> float(int(d))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: int too large to convert to float While for other functions of the module, like @tim-one, shouldn't we document this somehow? Maybe we could expose the |
I think this should be closed. We can open a separate issue for improving the documentation if that's needed. |
Uh oh!
There was an error while loading. Please reload this page.
issue is that for large x
math.log(Decimal(x))
returnsinf
I am not sure if that is an issue with documentation or implementation
The text was updated successfully, but these errors were encountered: