<p dir="auto">This behaviour might be related to these two bugs<br>
<a href="url">https://github.com/numpy/numpy/issues/5745</a><br>
<a href="url">https://github.com/numpy/numpy/issues/7126</a><br>
but regards int and not uint. I'm running the following code in both python2 and python3 with Numpy v.1.8.2 and v1.10.4.</p>
<p dir="auto">The issue comes up when running the following code:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np 
a = 9223372036854775808
type(a)
b = np.int64(0)
type(b)
type(b*a)"><pre class="notranslate"><code class="notranslate">import numpy as np 
a = 9223372036854775808
type(a)
b = np.int64(0)
type(b)
type(b*a)
</code></pre></div>
<p dir="auto">The result being (in Python3):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="builtins.int
numpy.int64
numpy.float64"><pre class="notranslate"><code class="notranslate">builtins.int
numpy.int64
numpy.float64
</code></pre></div>
<p dir="auto">Note that if I change it to:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="a = 9223372036854775807
type(b*a)"><pre class="notranslate"><code class="notranslate">a = 9223372036854775807
type(b*a)
</code></pre></div>
<p dir="auto">I get the correct casting:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="numpy.int64"><pre class="notranslate"><code class="notranslate">numpy.int64
</code></pre></div>
<p dir="auto">If I change the example to:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="a = 92233720368547758100
type(b*a)"><pre class="notranslate"><code class="notranslate">a = 92233720368547758100
type(b*a)
</code></pre></div>
<p dir="auto">I get again the expected (correct) casting:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="builtins.int"><pre class="notranslate"><code class="notranslate">builtins.int
</code></pre></div>
<p dir="auto">I came by this error while working with indices which should always be integer, so this casting to float64 was a very unexpected behaviour.</p>
<p dir="auto">Is this behavior expected?</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; print type(np.uint32(0) + int(0))
&lt;type 'numpy.int64'&gt;
&gt;&gt;&gt; print type(np.uint64(0) + int(0))
&lt;type 'numpy.float64'&gt;"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">print</span> <span class="pl-en">type</span>(<span class="pl-s1">np</span>.<span class="pl-en">uint32</span>(<span class="pl-c1">0</span>) <span class="pl-c1">+</span> <span class="pl-en">int</span>(<span class="pl-c1">0</span>))
<span class="pl-c1">&lt;</span><span class="pl-s1">type</span> <span class="pl-s">'numpy.int64'</span><span class="pl-c1">&gt;</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">print</span> <span class="pl-en">type</span>(<span class="pl-s1">np</span>.<span class="pl-en">uint64</span>(<span class="pl-c1">0</span>) <span class="pl-c1">+</span> <span class="pl-en">int</span>(<span class="pl-c1">0</span>))
<span class="pl-c1">&lt;</span><span class="pl-s1">type</span> <span class="pl-s">'numpy.float64'</span><span class="pl-c1">&gt;</span></pre></div>
<p dir="auto">The latter took me by surprise!</p>