-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Underflow should occur when evaluating exp for very small numbers #17893
Comments
Just taking a quick look at anther programming language I have with MPFR functionality gAwk
and unlike julia awk, does normally throw an exception on a underflow
So perhaps this suggests that it is accept-able to not raise exception on MFPR underflow. (Cos gAwk is a well known numerical programming language, right?) |
gmpy2, which I believe is the main python binding for mpfr (and GMP), does present an configurable option to throw an UnderflowError. Which seem like generally a good idea. |
There is a longstanding open issue for accessing floating point exceptions (#2976), but in the general case that is going to require work on LLVM itself. However we could expose some of the MPFR functionality; we probably don't want to throw an error by default (as silent underflow is the default behaviour for most floating point numbers), but we could enable a switch (similar to check_exception(BigFloat, Underflow) do
t = exp(-(sqrt(C * m) / ℏ))
end which would throw an error if any underflows occur inside. |
This can probably be closed as a being a subset of #2976 Since one of its points is:
|
When using exp function for very small numbers, instead of just returning 0, an underflow should occur. Consider the following snippet:
In the last line, t evalutes to 0.
The reason for this behavior was explained to me very elegantly here on Stack Overflow by Oxinabox
The text was updated successfully, but these errors were encountered: