strange conversion integer to float
Try this: $ python Python 2.7.1 (r271:86832, Apr 12 2011, 16:15:16) [GCC 4.6.0 20110331 (Red Hat 4.6.0-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import numpy as np np.__version__ '1.5.1' time=[] time.append(20091231) time_array=np.array(time,'f') time_array array([ 20091232.], dtype=float32) 20091231--->20091232 Why? Note: float(20091231) 20091231.0
Thanks, Alex.
Hi, If I remember correctly, float is a double (precision float). The precision is more important in doubles (float64) than in usual floats (float32). And 20091231 can not be reprensented in 32bits floats. Matthieu 2011/12/17 Alex van Houten <sparrow2867@yahoo.com>
Try this: $ python Python 2.7.1 (r271:86832, Apr 12 2011, 16:15:16) [GCC 4.6.0 20110331 (Red Hat 4.6.0-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import numpy as np np.__version__ '1.5.1' time=[] time.append(20091231) time_array=np.array(time,'f') time_array array([ 20091232.], dtype=float32) 20091231--->20091232 Why? Note: float(20091231) 20091231.0 Thanks, Alex.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
-- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher
participants (2)
-
Alex van Houten
-
Matthieu Brucher