t999.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. o=['+','-','*','/','**','%','<','=','>','<=','!=','>=']
  4. def oper(v1, v2, op):
  5. if (op == '+'):
  6. print " ",v1,op,v2,"=",v1+v2,type(v1+v2)
  7. elif (op == '-'):
  8. print " ",v1,op,v2,"=",v1-v2,type(v1-v2)
  9. elif (op == '*'):
  10. print " ",v1,op,v2,"=",v1*v2,type(v1*v2)
  11. elif (op == '/'):
  12. print " ",v1,op,v2,"=",v1/v2,type(v1/v2)
  13. elif (op == '**'):
  14. print " ",v1,op,v2,"=",v1**v2,type(v1**v2)
  15. elif (op == '%'):
  16. print " ",v1,op,v2,"=",v1%v2,type(v1%v2)
  17. elif (op == '<'):
  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. for x in v:
  30. print "Op 1 ::: ",type(x),x
  31. for y in v:
  32. print " Op 2 ::: ",type(y),y
  33. for z in o:
  34. try:
  35. oper(x, y, z)
  36. except:
  37. print "Can't ",type(x),z,type(y)