By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,538 Members | 1,428 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,538 IT Pros & Developers. It's quick & easy.

Strange behaviour of Numeric Float32 array?

P: n/a
Hi,

the code:

from Numeric import *

def my_minimum(a):
n=shape(a)[0]
x = 1.0e20
for i in range(n):
if a[i] < x:
x = a[i]
return x

def strange(a):
a[3] = -6303.0
h = my_minimum(a)
for i in range(10):
print i,a[i],
a[i] = a[i] - h
print a[i],h

a = zeros(10,Float32)
strange(a)
b = zeros(10,Float64)
strange(b)

produces the output:

0 0.0 6303.0 -6303.0
1 0.0 6303.0 -6303.0
2 0.0 6303.0 -6303.0
3 -6303.0 0.0 0.0
4 0.0 0.0 0.0
5 0.0 0.0 0.0
6 0.0 0.0 0.0
7 0.0 0.0 0.0
8 0.0 0.0 0.0
9 0.0 0.0 0.0
0 0.0 6303.0 -6303.0
1 0.0 6303.0 -6303.0
2 0.0 6303.0 -6303.0
3 -6303.0 0.0 -6303.0
4 0.0 6303.0 -6303.0
5 0.0 6303.0 -6303.0
6 0.0 6303.0 -6303.0
7 0.0 6303.0 -6303.0
8 0.0 6303.0 -6303.0
9 0.0 6303.0 -6303.0

Can anybody tell me why in the Float32 version h is changed?
Thank you in advance.

Regards

Rolf
Jul 12 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.