t371.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. print "==== simple ===="
  2. print int(314) == 314
  3. print int(3.14) == 3
  4. print int(314L) == 314
  5. print int(-3.14) == -3
  6. print int(3.9) == 3
  7. print int(-3.9) == -3
  8. print int(3.5) == 3
  9. print int(-3.5) == -3
  10. print int("10",16) == 16L
  11. print "==== int with bases ===="
  12. print int('100000000000000000000000000000000', 2) == 4294967296L
  13. print int('102002022201221111211', 3) == 4294967296L
  14. print int('10000000000000000', 4) == 4294967296L
  15. print int('32244002423141', 5) == 4294967296L
  16. print int('1550104015504', 6) == 4294967296L
  17. print int('211301422354', 7) == 4294967296L
  18. print int('40000000000', 8) == 4294967296L
  19. print int('12068657454', 9) == 4294967296L
  20. print int('4294967296', 10) == 4294967296L
  21. print int('1904440554', 11) == 4294967296L
  22. print int('9ba461594', 12) == 4294967296L
  23. print int('535a79889', 13) == 4294967296L
  24. print int('2ca5b7464', 14) == 4294967296L
  25. print int('1a20dcd81', 15) == 4294967296L
  26. print int('100000000', 16) == 4294967296L
  27. print int('a7ffda91', 17) == 4294967296L
  28. print int('704he7g4', 18) == 4294967296L
  29. print int('4f5aff66', 19) == 4294967296L
  30. print int('3723ai4g', 20) == 4294967296L
  31. print int('281d55i4', 21) == 4294967296L
  32. print int('1fj8b184', 22) == 4294967296L
  33. print int('1606k7ic', 23) == 4294967296L
  34. print int('mb994ag', 24) == 4294967296L
  35. print int('hek2mgl', 25) == 4294967296L
  36. print int('dnchbnm', 26) == 4294967296L
  37. print int('b28jpdm', 27) == 4294967296L
  38. print int('8pfgih4', 28) == 4294967296L
  39. print int('76beigg', 29) == 4294967296L
  40. print int('5qmcpqg', 30) == 4294967296L
  41. print int('4q0jto4', 31) == 4294967296L
  42. print int('4000000', 32) == 4294967296L
  43. print int('3aokq94', 33) == 4294967296L
  44. print int('2qhxjli', 34) == 4294967296L
  45. print int('2br45qb', 35) == 4294967296L
  46. print int('1z141z4', 36) == 4294967296L
  47. print int('-100000000000000000000000000000000', 2) == -4294967296L
  48. print int('-102002022201221111211', 3) == -4294967296L
  49. print int('-10000000000000000', 4) == -4294967296L
  50. print int('-32244002423141', 5) == -4294967296L
  51. print int('-1550104015504', 6) == -4294967296L
  52. print int('-211301422354', 7) == -4294967296L
  53. print int('-40000000000', 8) == -4294967296L
  54. print int('-12068657454', 9) == -4294967296L
  55. print int('-4294967296', 10) == -4294967296L
  56. print int('-1904440554', 11) == -4294967296L
  57. print int('-9ba461594', 12) == -4294967296L
  58. print int('-535a79889', 13) == -4294967296L
  59. print int('-2ca5b7464', 14) == -4294967296L
  60. print int('-1a20dcd81', 15) == -4294967296L
  61. print int('-100000000', 16) == -4294967296L
  62. print int('-a7ffda91', 17) == -4294967296L
  63. print int('-704he7g4', 18) == -4294967296L
  64. print int('-4f5aff66', 19) == -4294967296L
  65. print int('-3723ai4g', 20) == -4294967296L
  66. print int('-281d55i4', 21) == -4294967296L
  67. print int('-1fj8b184', 22) == -4294967296L
  68. print int('-1606k7ic', 23) == -4294967296L
  69. print int('-mb994ag', 24) == -4294967296L
  70. print int('-hek2mgl', 25) == -4294967296L
  71. print int('-dnchbnm', 26) == -4294967296L
  72. print int('-b28jpdm', 27) == -4294967296L
  73. print int('-8pfgih4', 28) == -4294967296L
  74. print int('-76beigg', 29) == -4294967296L
  75. print int('-5qmcpqg', 30) == -4294967296L
  76. print int('-4q0jto4', 31) == -4294967296L
  77. print int('-4000000', 32) == -4294967296L
  78. print int('-3aokq94', 33) == -4294967296L
  79. print int('-2qhxjli', 34) == -4294967296L
  80. print int('-2br45qb', 35) == -4294967296L
  81. print int('-1z141z4', 36) == -4294967296L
  82. print "==== long with bases ===="
  83. print long('100000000000000000000000000000000', 2) == 4294967296L
  84. print long('102002022201221111211', 3) == 4294967296L
  85. print long('10000000000000000', 4) == 4294967296L
  86. print long('32244002423141', 5) == 4294967296L
  87. print long('1550104015504', 6) == 4294967296L
  88. print long('211301422354', 7) == 4294967296L
  89. print long('40000000000', 8) == 4294967296L
  90. print long('12068657454', 9) == 4294967296L
  91. print long('4294967296', 10) == 4294967296L
  92. print long('1904440554', 11) == 4294967296L
  93. print long('9ba461594', 12) == 4294967296L
  94. print long('535a79889', 13) == 4294967296L
  95. print long('2ca5b7464', 14) == 4294967296L
  96. print long('1a20dcd81', 15) == 4294967296L
  97. print long('100000000', 16) == 4294967296L
  98. print long('a7ffda91', 17) == 4294967296L
  99. print long('704he7g4', 18) == 4294967296L
  100. print long('4f5aff66', 19) == 4294967296L
  101. print long('3723ai4g', 20) == 4294967296L
  102. print long('281d55i4', 21) == 4294967296L
  103. print long('1fj8b184', 22) == 4294967296L
  104. print long('1606k7ic', 23) == 4294967296L
  105. print long('mb994ag', 24) == 4294967296L
  106. print long('hek2mgl', 25) == 4294967296L
  107. print long('dnchbnm', 26) == 4294967296L
  108. print long('b28jpdm', 27) == 4294967296L
  109. print long('8pfgih4', 28) == 4294967296L
  110. print long('76beigg', 29) == 4294967296L
  111. print long('5qmcpqg', 30) == 4294967296L
  112. print long('4q0jto4', 31) == 4294967296L
  113. print long('4000000', 32) == 4294967296L
  114. print long('3aokq94', 33) == 4294967296L
  115. print long('2qhxjli', 34) == 4294967296L
  116. print long('2br45qb', 35) == 4294967296L
  117. print long('1z141z4', 36) == 4294967296L
  118. print "==== simple truncation ===="
  119. print int(1.2) == 1
  120. print int('100', 2) == 4
  121. print long(1.2) == 1
  122. print long('100', 2) == 4
  123. print "==== base 0 ===="
  124. print int(' 0123 ', 0) == 83
  125. print int(' 0123 ', 0) == 83
  126. print int('000', 0) == 0
  127. print int('0o123', 0) == 83
  128. print int('0x123', 0) == 291
  129. print int('0b100', 0) == 4
  130. print int(' 0O123 ', 0) == 83
  131. print int(' 0X123 ', 0) == 291
  132. print int(' 0B100 ', 0) == 4
  133. print int('0', 0) == 0
  134. print int('+0', 0) == 0
  135. print int('-0', 0) == 0
  136. print int('00', 0) == 0
  137. print "==== base 10 ===="
  138. print int('0123') == 123
  139. print int('0123', 10) == 123
  140. print "==== base with prefix ===="
  141. print int('0x123', 16) == 291
  142. print int('0o123', 8) == 83
  143. print int('0b100', 2) == 4
  144. print int('0X123', 16) == 291
  145. print int('0O123', 8) == 83
  146. print int('0B100', 2) == 4
  147. print "==== int -> long ===="
  148. print int('1' * 600)