<p dir="auto">See:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/4319522/12889519/4d06f3f6-ce4d-11e5-9f36-b2e05f96cccc.png"><img src="https://cloud.githubusercontent.com/assets/4319522/12889519/4d06f3f6-ce4d-11e5-9f36-b2e05f96cccc.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">This could be confusing to newcomers, who may misinterpret this as julia calling python these python function.</p>
<p dir="auto">Hi guys,</p>
<p dir="auto">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:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="4.604716014154575e-19*(10000000000)^2 = -46.047160141545149"><pre class="notranslate"><code class="notranslate">4.604716014154575e-19*(10000000000)^2 = -46.047160141545149
</code></pre></div>
<p dir="auto">First, I was using the <code class="notranslate">^</code>, but it was providing a wrong answer:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; 4.604716014154575e-19*10000000000^2
3.5761512189350633"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">4.604716014154575e-19</span><span class="pl-k">*</span><span class="pl-c1">10000000000</span><span class="pl-k">^</span><span class="pl-c1">2</span>
<span class="pl-c1">3.5761512189350633</span></pre></div>
<p dir="auto">If I drop the <code class="notranslate">^</code> and multiply two times, then the result is correct:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; 4.604716014154575e-19*10000000000*10000000000
46.04716014154576"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">4.604716014154575e-19</span><span class="pl-k">*</span><span class="pl-c1">10000000000</span><span class="pl-k">*</span><span class="pl-c1">10000000000</span>
<span class="pl-c1">46.04716014154576</span></pre></div>
<p dir="auto">I tested it in Julia v0.6.2 and v0.6.3 in macOS and Linux with the same behavior. I think the operation <code class="notranslate">10000000000^2</code> is overflowing <code class="notranslate">Int64</code> and with <code class="notranslate">^</code> this is computed first. On the other hand, using the multiplication, the first operation is <code class="notranslate">4.604716014154575e-19*10000000000</code>, which does not cause any overflow.</p>
<p dir="auto">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?</p>