Saturday, 15 February 2014

What's wrong with sum(65537) in Python? -


I am using Python 3.3.2 x64 and when I type sum () function Large for a category 65536 :

  Yoga (category (65537)) -2147450880  

This 'scientific' version preload NumPy and SciPy library.

What is the problem?

I think you should use Python instead of numpy.sum () There is a problem with the built in sum () function. According to:

dtype : type of array and type of accumulator in which the elements are summed. By default, one's dtype is used. An exception occurs when an integer type is less accurate than the default platform integer. In that case, the default platform integer is used instead. Try setting manually

dtype :

  import np np np .sum (category (65537) , Dtype = np.int64)  

Result:

  2147516416  

No comments:

Post a Comment