t343.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. print "Big number test"
  2. v=[1,1.0,1L,-1,-1.0,-1L,2,2.0,2L,-2,-2.0,-2L,1e9,-1e9,1e-9,-1e-9,123456789L,12345678901234567890123456789L]
  3. #v=[2,2.0,2L,-2,-2.0,-2L,123456789L,12345678901234567890123456789L]
  4. o=['+','-','*','/','**','%','<','=','>','<=','!=','>=']
  5. def oper(v1, v2, op):
  6. if (op == '+'):
  7. print " ",v1,op,v2,"=",v1+v2,type(v1+v2)
  8. elif (op == '-'):
  9. print " ",v1,op,v2,"=",v1-v2,type(v1-v2)
  10. elif (op == '*'):
  11. print " ",v1,op,v2,"=",v1*v2,type(v1*v2)
  12. elif (op == '/'):
  13. print " ",v1,op,v2,"=",v1/v2,type(v1/v2)
  14. elif (op == '**'):
  15. if v2 > 100000000:
  16. print 'skipping pow of really big number'
  17. return
  18. print " ",v1,op,v2,"=",v1**v2,type(v1**v2)
  19. elif (op == '%'):
  20. print " ",v1,op,v2,"=",v1%v2,type(v1%v2)
  21. elif (op == '<'):
  22. print " ",v1,op,v2,"=",v1<v2,type(v1<v2)
  23. elif (op == '='):
  24. print " ",v1,op,v2,"=",v1==v2,type(v1==v2)
  25. elif (op == '>'):
  26. print " ",v1,op,v2,"=",v1>v2,type(v1>v2)
  27. elif (op == '<='):
  28. print " ",v1,op,v2,"=",v1<=v2,type(v1<=v2)
  29. elif (op == '!='):
  30. print " ",v1,op,v2,"=",v1!=v2,type(v1!=v2)
  31. elif (op == '>='):
  32. print " ",v1,op,v2,"=",v1>=v2,type(v1>=v2)
  33. for x in v:
  34. print "Op 1 ::: ",type(x),x
  35. for y in v:
  36. print " Op 2 ::: ",type(y),y
  37. for z in o:
  38. try:
  39. oper(x, y, z)
  40. except:
  41. print "Can't ",type(x),z,type(y)