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:

I16 np.float32(5555)*5e38
O16 2.7774999999999998e+42

I17 (np.float32(5555)*5e38).dtype
O17 dtype('float64')

IDL> help, 5e38*float(5555)
<Expression>    FLOAT     =           Inf

In IDL, the expression doesn't get converted to DOUBLE. Perhaps, its a
design decision.


On Thu, Nov 15, 2012 at 8:24 PM, Gökhan Sever <gokhanse...@gmail.com> wrote:

> Hello,
>
> 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')[0]).dtype
> O3 dtype('float32')
>
> I4 (1*np.arange(5, dtype='float32')[0]).dtype
> O4 dtype('float64')
>
>
>
> Thanks.
>
>
>
>
> --
> Gökhan
>



-- 
Gökhan
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to