<h3 dir="auto">Describe the issue:</h3>
<p dir="auto">Using <code class="notranslate">astype(np.float32)</code> on integer array corrupts the data on ppc64el platform using numpy from conda-forge.</p>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="np.array([1, 0, 1, 0, 1, 0], dtype=int).astype(np.float32)"><pre class="notranslate"><span class="pl-s1">np</span>.<span class="pl-en">array</span>([<span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">1</span>, <span class="pl-c1">0</span>], <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">int</span>).<span class="pl-en">astype</span>(<span class="pl-s1">np</span>.<span class="pl-s1">float32</span>)</pre></div>
<h3 dir="auto">Error message:</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="array([0.0000000e+00, 0.0000000e+00,           nan, 2.3509886e-38,
       1.0000000e+00, 0.0000000e+00], dtype=float32)"><pre class="notranslate">array([0.0000000e+00, 0.0000000e+00,           nan, 2.3509886e-38,
       1.0000000e+00, 0.0000000e+00], dtype=float32)</pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="

### NumPy/Python version information:

1.22.3 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:42:07) [GCC 10.3.0]"><pre class="notranslate"><code class="notranslate">

### NumPy/Python version information:

1.22.3 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:42:07) [GCC 10.3.0]
</code></pre></div>
<h3 dir="auto">Describe the issue:</h3>
<p dir="auto"><em>[I want to begin by first acknowledging that this is a fringe case of a bug appearing only in a VM (I haven't yet been able to reproduce it on real hardware), so please feel free to close this issue right away. However, I felt that I still should at least point it out, in case there is some latent real issue that this might uncover. In any case, hints as to how I can dig deeper into this so that I may report it to the proper channel (be it QEMU, GNU libc, or whatever) would be welcome.]</em></p>
<p dir="auto">On a QEMU ppc64le VM, When casting an array of floats to <code class="notranslate">np.intc</code>, a weird truncation seems to happen. This only occurs in the VM; it does not happen onthe  real ppc64le hardware I had access to (although that system hat an older 4.19 kernel; I cannot change that).</p>
<p dir="auto">In the code below, I create arrays of value <code class="notranslate">1.</code> of length 1 through 10,  and then cast them to <code class="notranslate">np.int64</code> and <code class="notranslate">np.intc</code> for comparison.</p>
<p dir="auto">This works fine for arrays with length &lt;= 3. If fails for longer ones, and apparently there is a pattern in this failure.</p>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
for i in range(1, 11):
    a = np.full(i, 1.)
    print(i, a, a.astype(np.int64), a.astype(np.intc))"><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-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">1</span>, <span class="pl-c1">11</span>):
    <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">full</span>(<span class="pl-s1">i</span>, <span class="pl-c1">1.</span>)
    <span class="pl-en">print</span>(<span class="pl-s1">i</span>, <span class="pl-s1">a</span>, <span class="pl-s1">a</span>.<span class="pl-en">astype</span>(<span class="pl-s1">np</span>.<span class="pl-s1">int64</span>), <span class="pl-s1">a</span>.<span class="pl-en">astype</span>(<span class="pl-s1">np</span>.<span class="pl-s1">intc</span>))</pre></div>
<h3 dir="auto">Error message:</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="1 [1.] [1] [1]
2 [1. 1.] [1 1] [1 1]
3 [1. 1. 1.] [1 1 1] [1 1 1]
4 [1. 1. 1. 1.] [1 1 1 1] [0 0 0 0]
5 [1. 1. 1. 1. 1.] [1 1 1 1 1] [0 0 0 0 1]
6 [1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1] [0 0 0 0 1 1]
7 [1. 1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1 1] [0 0 0 0 1 1 1]
8 [1. 1. 1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1 1 1] [0 0 0 0 0 0 0 0]
9 [1. 1. 1. 1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1 1 1 1] [0 0 0 0 0 0 0 0 1]
10 [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1 1 1 1 1] [0 0 0 0 0 0 0 0 1 1]"><pre class="notranslate">1 [1.] [1] [1]
2 [1. 1.] [1 1] [1 1]
3 [1. 1. 1.] [1 1 1] [1 1 1]
4 [1. 1. 1. 1.] [1 1 1 1] [0 0 0 0]
5 [1. 1. 1. 1. 1.] [1 1 1 1 1] [0 0 0 0 1]
6 [1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1] [0 0 0 0 1 1]
7 [1. 1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1 1] [0 0 0 0 1 1 1]
8 [1. 1. 1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1 1 1] [0 0 0 0 0 0 0 0]
9 [1. 1. 1. 1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1 1 1 1] [0 0 0 0 0 0 0 0 1]
10 [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] [1 1 1 1 1 1 1 1 1 1] [0 0 0 0 0 0 0 0 1 1]</pre></div>
<h3 dir="auto">NumPy/Python version information:</h3>
<p dir="auto">1.22.1 3.9.10 (main, Jan 16 2022, 17:12:18)<br>
[GCC 11.2.0]</p>