I recently discovered that x**.5
and math.sqrt(x)
do not always produce the same result in Python:
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)]
on win32
>>> 8885558**.5 - math.sqrt(8885558)
-4.5474735088646412e-13
Checking all integers below 10**7 produced an error rate of almost exactly 0.1%, with the size of the error increasing (slowly) for larger numbers.
So the question is, which method is more accurate?
Edit: For the record, this isn't current causing me issues, nor do I know of a case where it might. But it's a slow Friday afternoon, so I ask out of curiosity and in the name of best practices. :-)