Peter Otten wrote:

> (Specifying dtype=float forces floating point arithmetic which is inexact)

I found a way to avoid the error:

>>> import numpy as np
>>> def sum2(N):
...     a = np.arange(1, N+1, dtype=object)
...     return (2*(1+3**(a-1))).sum()
... 
>>> sum2(50)
717897987691852588770348

As this operates on int objects rather than C/machine language numbers this  
will probably be significantly slower than dtype=int or dtype=float.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to