Odd behavior when multiplying numpy array by a constant (e.g. 1/100)
<p>I create the following random array and I multiply it times a constant but get an unexpected result (zeros instead of the answer I expect):</p>

<pre><code>In [4]: A = np.random.rand(1,11)

In [5]: A
Out[5]: 
array([[ 0.15138551,  0.41573765,  0.0212214 ,  0.44955909,  0.27013062,
         0.37835199,  0.89712845,  0.95333785,  0.09920397,  0.2303608 ,
         0.11246899]])

In [6]: A*(1/100)
Out[6]: array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]])

In [7]: A/100
Out[7]: 
array([[ 0.00151386,  0.00415738,  0.00021221,  0.00449559,  0.00270131,
         0.00378352,  0.00897128,  0.00953338,  0.00099204,  0.00230361,
         0.00112469]])
</code></pre>

<p>What is the reason for this? Seems extremely counterintuitive.</p>

<p>You are using python2 and <code>1/100</code> is integer division, resulting in <code>0</code>.</p>

<p>Use floating points:</p>

<pre><code>A * (1.0/100)
</code></pre>

<p>or use a future import:</p>

<pre><code>from __future__ import division
</code></pre>

<p>to enable floating point division for integers, too.</p>

python numpy python-2.x