<h3 dir="auto">Reproducing code example:</h3>
<p dir="auto">On my ARM Chromebook, running Debian 9.9 under Crouton I have a problem where the answer should be 'NaT', but I am getting '1970-01-01T00:00:00.000000000'.</p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
x = np.array([1,2,np.nan,np.nan]).astype('M8[ns]')
print(x)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-s1">np</span>.<span class="pl-s1">nan</span>,<span class="pl-s1">np</span>.<span class="pl-s1">nan</span>]).<span class="pl-en">astype</span>(<span class="pl-s">'M8[ns]'</span>)
<span class="pl-en">print</span>(<span class="pl-s1">x</span>)</pre></div>
<p dir="auto">Will print:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="array(['1970-01-01T00:00:00.000000001', '1970-01-01T00:00:00.000000002',
       '1970-01-01T00:00:00.000000000', '1970-01-01T00:00:00.000000000'],
      dtype='datetime64[ns]')"><pre class="notranslate"><code class="notranslate">array(['1970-01-01T00:00:00.000000001', '1970-01-01T00:00:00.000000002',
       '1970-01-01T00:00:00.000000000', '1970-01-01T00:00:00.000000000'],
      dtype='datetime64[ns]')
</code></pre></div>

<h3 dir="auto">Error message:</h3>
<p dir="auto">No error message.</p>


<h3 dir="auto">Numpy/Python version information:</h3>

<p dir="auto">1.16.3 3.7.3 (default, May 22 2019, 00:01:31)<br>
[GCC 6.3.0 20170516]</p>
<p dir="auto">Doing some calculations I discover this unexpected behavior related with<br>
<code class="notranslate">dtypes</code>. I hope some of you can point me if this is a bug or I'm doing<br>
something wrong.</p>
<h3 dir="auto">Reproducing code example:</h3>
<p dir="auto">Here is a minimal peace of my code which tries to reproduce the problem:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np

# VERSIONS USED
np.__version__ #  '1.18.1'
np.__version__ #  '1.19.0'

x = 731965.048356481480000000000000000000
x_arr = np.array([x])
big_int = 86400000000000
cnst = 719529

# THIS WORKS
arr1 = (x_arr - cnst) * big_int
out1 = arr1.astype(&quot;datetime64[ns]&quot;)

# THIS FAILS
arr2 = x_arr * big_int - cnst * big_int
out2 = arr2.astype(&quot;datetime64[ns]&quot;)

# WORKAROUND
big_int = 86400000000000.  # NOW IS A FLOAT
arr3 = x_arr * big_int - cnst * big_int
out3 = arr3.astype(&quot;datetime64[ns]&quot;)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-c"># VERSIONS USED</span>
<span class="pl-s1">np</span>.<span class="pl-s1">__version__</span> <span class="pl-c">#  '1.18.1'</span>
<span class="pl-s1">np</span>.<span class="pl-s1">__version__</span> <span class="pl-c">#  '1.19.0'</span>

<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-c1">731965.048356481480000000000000000000</span>
<span class="pl-s1">x_arr</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-s1">x</span>])
<span class="pl-s1">big_int</span> <span class="pl-c1">=</span> <span class="pl-c1">86400000000000</span>
<span class="pl-s1">cnst</span> <span class="pl-c1">=</span> <span class="pl-c1">719529</span>

<span class="pl-c"># THIS WORKS</span>
<span class="pl-s1">arr1</span> <span class="pl-c1">=</span> (<span class="pl-s1">x_arr</span> <span class="pl-c1">-</span> <span class="pl-s1">cnst</span>) <span class="pl-c1">*</span> <span class="pl-s1">big_int</span>
<span class="pl-s1">out1</span> <span class="pl-c1">=</span> <span class="pl-s1">arr1</span>.<span class="pl-en">astype</span>(<span class="pl-s">"datetime64[ns]"</span>)

<span class="pl-c"># THIS FAILS</span>
<span class="pl-s1">arr2</span> <span class="pl-c1">=</span> <span class="pl-s1">x_arr</span> <span class="pl-c1">*</span> <span class="pl-s1">big_int</span> <span class="pl-c1">-</span> <span class="pl-s1">cnst</span> <span class="pl-c1">*</span> <span class="pl-s1">big_int</span>
<span class="pl-s1">out2</span> <span class="pl-c1">=</span> <span class="pl-s1">arr2</span>.<span class="pl-en">astype</span>(<span class="pl-s">"datetime64[ns]"</span>)

<span class="pl-c"># WORKAROUND</span>
<span class="pl-s1">big_int</span> <span class="pl-c1">=</span> <span class="pl-c1">86400000000000.</span>  <span class="pl-c"># NOW IS A FLOAT</span>
<span class="pl-s1">arr3</span> <span class="pl-c1">=</span> <span class="pl-s1">x_arr</span> <span class="pl-c1">*</span> <span class="pl-s1">big_int</span> <span class="pl-c1">-</span> <span class="pl-s1">cnst</span> <span class="pl-c1">*</span> <span class="pl-s1">big_int</span>
<span class="pl-s1">out3</span> <span class="pl-c1">=</span> <span class="pl-s1">arr3</span>.<span class="pl-en">astype</span>(<span class="pl-s">"datetime64[ns]"</span>)</pre></div>
<h4 dir="auto">MWE</h4>
<p dir="auto">Here some code that I use for debugging a minimal reproducible example that<br>
shows this unexpected behavior.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="def check_dtype(big_int):
    a = np.array([731965.04835648148]) * big_int
    b = 719529 * big_int
    c = a - b
    return c.dtype

works_int = 20000000000000
fails_int = 30000000000000
check_dtype(works_int)  # dtype('float64')
check_dtype(fails_int)  # dtype('O')"><pre class="notranslate"><span class="pl-k">def</span> <span class="pl-en">check_dtype</span>(<span class="pl-s1">big_int</span>):
    <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">731965.04835648148</span>]) <span class="pl-c1">*</span> <span class="pl-s1">big_int</span>
    <span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-c1">719529</span> <span class="pl-c1">*</span> <span class="pl-s1">big_int</span>
    <span class="pl-s1">c</span> <span class="pl-c1">=</span> <span class="pl-s1">a</span> <span class="pl-c1">-</span> <span class="pl-s1">b</span>
    <span class="pl-k">return</span> <span class="pl-s1">c</span>.<span class="pl-s1">dtype</span>

<span class="pl-s1">works_int</span> <span class="pl-c1">=</span> <span class="pl-c1">20000000000000</span>
<span class="pl-s1">fails_int</span> <span class="pl-c1">=</span> <span class="pl-c1">30000000000000</span>
<span class="pl-en">check_dtype</span>(<span class="pl-s1">works_int</span>)  <span class="pl-c"># dtype('float64')</span>
<span class="pl-en">check_dtype</span>(<span class="pl-s1">fails_int</span>)  <span class="pl-c"># dtype('O')</span></pre></div>
<h3 dir="auto">Numpy/Python version information:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import sys, numpy; print(numpy.__version__, sys.version)
1.19.0 3.7.7 (default, Mar 26 2020, 15:48:22)
[GCC 7.3.0]"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">sys</span>, <span class="pl-s1">numpy</span>; <span class="pl-en">print</span>(<span class="pl-s1">numpy</span>.<span class="pl-s1">__version__</span>, <span class="pl-s1">sys</span>.<span class="pl-s1">version</span>)
<span class="pl-c1">1.19</span>.<span class="pl-c1">0</span> <span class="pl-c1">3.7</span>.<span class="pl-c1">7</span> (<span class="pl-s1">default</span>, <span class="pl-v">Mar</span> <span class="pl-c1">26</span> <span class="pl-c1">2020</span>, <span class="pl-c1">15</span>:<span class="pl-c1">48</span>:<span class="pl-c1">22</span>)
[<span class="pl-v">GCC</span> <span class="pl-c1">7.3</span><span class="pl-c1">.0</span>]</pre></div>