Confusing math problem

Schizoid Man schiz_man at 21stcentury.com
Thu Feb 21 20:33:32 CET 2013


Hi there,

I run the following code in Python 3.3.0 (on a Windows 7 machine) and Python 
2.7.3 on a Mac and I get two different results:

result1 = []
result2 = []
for a in range(2,101):
    for b in range(2,101):
        result1.append(math.pow(a,b))
        result2.append(a**b)
result1 = list(set(result1))
result2 = list(set(result2))
print (len(result1))
print (len(result2))

On the Windows box, I get 9183 for on both lines. However, on the Mac I get 
9220 and 9183. Why this difference? Is there some sort of precision subtlety 
I'm missing between ** and math.pow()?

Thank you. 




More information about the Python-list mailing list