Hi all,
I am trying to get a list of ordered pairs from the below function. In
my code, evaluate is more exciting, but the evaluate here will at
least let this run. The below runs fine, with one exception: somehow,
it is saying that -2+2.0 is 4.x, where x is a huge decimal involving
E-16 (in other words, a really tiny number). Does anyone have any idea
what is going on here?

def getCoords(f, e1, e2, step=.1):
 #returns a list of (x,y) tuples from e1 to e2 at the given accuracy (step)
 time=0
 i=0
 coords=[]
 while time<=e2:
  print "time="+str(e1)+"+"+str(i)+"="
  time=e1+i
  print time #watch this line when above is -2+2.0
  coords.append((time, evaluate(f, time)))
  i=i+1*step
 return coords

def evaluate(x,y): return x*y
-- 
Have a great day,
Alex (msg sent from GMail website)
mehg...@gmail.com; http://www.facebook.com/mehgcap
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to