-
-
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
Wrong result when multiplying a very small number and a very big one using ^ #27355
Comments
Duplicate of #855 |
Note that this works in Matlab because the literal |
@mbauman thanks! I will follow that bug. |
Its best to ask these questions on discourse.julialang.org. |
Sorry but it really looked like a bug to me. Actually, IMHO, I think this should be considered a bug. |
You may not like it but it is not a bug as it is both intentional and thoroughly documented. |
Ok then... |
Hi guys,
I was implementing a algorithm, comparing to MATLAB version, and I found a very strange behavior in Julia. I need to perform the following multiplication:
First, I was using the
^
, but it was providing a wrong answer:If I drop the
^
and multiply two times, then the result is correct:I tested it in Julia v0.6.2 and v0.6.3 in macOS and Linux with the same behavior. I think the operation
10000000000^2
is overflowingInt64
and with^
this is computed first. On the other hand, using the multiplication, the first operation is4.604716014154575e-19*10000000000
, which does not cause any overflow.However, I think Julia should be able to handle that just as MATLAB can. At least a warning about the overflow should be printed. Otherwise, sometimes can be very difficult to debug this. What do you think?
The text was updated successfully, but these errors were encountered: