<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; 128738872312*invmod(128738872312,9223372036854775783)
9223369465230597584

julia&gt; ans &lt; 9223372036854775783
true"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">128738872312</span><span class="pl-k">*</span><span class="pl-c1">invmod</span>(<span class="pl-c1">128738872312</span>,<span class="pl-c1">9223372036854775783</span>)
<span class="pl-c1">9223369465230597584</span>

julia<span class="pl-k">&gt;</span> ans <span class="pl-k">&lt;</span> <span class="pl-c1">9223372036854775783</span>
<span class="pl-c1">true</span></pre></div>
<p dir="auto">To deal with integer arithmetic overflow we do the following:</p>
<ol dir="auto">
<li>add checked integer arithmetic intrinsics named <code class="notranslate">checked_add</code>, <code class="notranslate">checked_mul</code>, etc.</li>
<li>have a compiler switch that uses these everywhere.</li>
<li>write a <code class="notranslate">@check_overflow</code> macro that transforms an expression to turn <code class="notranslate">*</code> into <code class="notranslate">checked_mul</code> and <code class="notranslate">+</code> into <code class="notranslate">checked_add</code>, etc., but only in the expression — called functions are on their own.</li>
</ol>