t430.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. print "\nINTEGERS"
  2. # binary
  3. print 0b0101 | 0b1010 == 0b1111
  4. print 0b0110 ^ 0b0101 == 0b0011
  5. print 0b1111 & 0b0001 == 0b0001
  6. print 0b0110 << 2 == 0b11000
  7. print 0b0110 >> 2 == 0b0001
  8. print ~0b0011 == -0b0100
  9. # octal
  10. print 0O0505 | 0O1000 == 0O1505
  11. print 0O1200 ^ 0O1034 == 0O0234
  12. print 0O7740 & 0O7400 == 0O7400
  13. print 0O2763 << 2 == 0O13714
  14. print 0O2763 >> 2 == 0O574
  15. print ~0O1234 == -0O1235
  16. # hexadecimal
  17. print 0x0ff0 | 0x0000 == 0x0ff0
  18. print 0x10f0 ^ 0x01f0 == 0x1100
  19. print 0x0ff0 & 0xf00f == 0x0000
  20. print 0x5a01 << 2 == 0x16804
  21. print 0x5a01 >> 2 == 0x1680
  22. print ~0x4a30 == -0x4a31
  23. # decimal
  24. print 124 | 37 == 125
  25. print 3847 ^ 4958 == 7257
  26. print 745 & 348 == 72
  27. print 1834 << 2 == 7336
  28. print 1834 >> 2 == 458
  29. print ~2398 == -2399
  30. print "\nLONG INTEGERS"
  31. # binary # skulpt doesn't accept binary longs
  32. '''
  33. print 0b0101L | 0b1010L == 0b1111L
  34. print 0b0110L ^ 0b0101L == 0b0011L
  35. print 0b1111L & 0b0001L == 0b0001L
  36. print 0b0110L << 2L == 0b11000L
  37. print 0b0110L >> 2L == 0b0001L
  38. #print ~0b0011L == -0b0100L #skulpt doesn't accept the ~ operator with longs
  39. '''
  40. # octal
  41. print 0O0505L | 0O1000L == 0O1505L
  42. print 0O1200L ^ 0O1034L == 0O0234L
  43. print 0O7740L & 0O7400L == 0O7400L
  44. print 0O2763L << 2L == 0O13714L
  45. print 0O2763L >> 2L == 0O574L
  46. #print ~0O1234L == -0O1235L #skulpt doesn't accept the ~ operator with longs
  47. # hexadecimal
  48. print 0x0ff0L | 0x0000L == 0x0ff0L
  49. print 0x10f0L ^ 0x01f0L == 0x1100L
  50. print 0x0ff0L & 0xf00fL == 0x0000L
  51. print 0x5a01L << 2L == 0x16804L
  52. print 0x5a01L >> 2L == 0x1680L
  53. #print ~0x4a30L == -0x4a31L #skulpt doesn't accept the ~ operator with longs
  54. # decimal
  55. print 124L | 37L == 125L
  56. print 3847L ^ 4958L == 7257L
  57. print 745L & 348L == 72L
  58. print 1834L << 2L == 7336L
  59. print 1834L >> 2L == 458L
  60. #print ~2398L == -2399L #skulpt doesn't accept the ~ operator with longs
  61. print int('123456789'*10) & int('987654321'*10) == 95579309557357885362290225874030292317027763371981185445626785720401260273886076820525585
  62. print type(int('123456789'*10) & int('987654321'*10))