[Numpy-discussion] float32 to float64 casting
Fri Nov 16 15:53:07 CST 2012
Thanks for the explanations.
For either case, I was expecting to get float32 as a resulting data type.
Since, float32 is large enough to contain the result. I am wondering if
changing casting rule this way, requires a lot of modification in the NumPy
code. Maybe as an alternative to the current casting mechanism?
I like the way that NumPy can convert to float64. As if these data-types
are continuation of each other. But just the conversation might happen too
early --at least in my opinion, as demonstrated in my example.
For instance comparing this example to IDL surprises me:
IDL> help, 5e38*float(5555)
<Expression> FLOAT = Inf
In IDL, the expression doesn't get converted to DOUBLE. Perhaps, its a
On Thu, Nov 15, 2012 at 8:24 PM, Gökhan Sever <firstname.lastname@example.org> wrote:
> Could someone briefly explain why are these two operations are casting my
> float32 arrays to float64?
> I1 (np.arange(5, dtype='float32')).dtype
> O1 dtype('float32')
> I2 (100000*np.arange(5, dtype='float32')).dtype
> O2 dtype('float64')
> I3 (np.arange(5, dtype='float32')).dtype
> O3 dtype('float32')
> I4 (1*np.arange(5, dtype='float32')).dtype
> O4 dtype('float64')
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion