[Numpy-discussion] type coercion question

Chris Barker Chris.Barker at noaa.gov
Wed Mar 31 09:23:05 CST 2004


On Mar 31, 2004, at 7:39 AM, Perry Greenfield wrote:
> Just to summarize what I see as acceptable choices:
>
> 1) ints promote to Float32 (current behavior)
> 2) ints promote to Float64
> 3) Int32 promotes to Float64, lesser ints promote to Float32 (Numeric
> behavior)

+1 on (2)

I want math.cos(x) to give the same answer as numarray.cos( array( (x) 
) ) as much as possible. I like that Numarray does not do as much 
auto-upcasting as Numeric, but if I want to control the size of my data 
arrays, I'm not going to be passing an int into a floating point 
function. i.e, I can always do:

cos( array( (x), Float32 ) )

Then I would want the result to be a Float32

-Chris


Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov





More information about the Numpy-discussion mailing list