int_big_mul.py 453 B

1234567891011121314151617181920212223
  1. # tests transition from small to large int representation by multiplication
  2. for rhs in range(2, 11):
  3. lhs = 1
  4. for k in range(100):
  5. res = lhs * rhs
  6. print(lhs, '*', rhs, '=', res)
  7. lhs = res
  8. # below tests pos/neg combinations that overflow small int
  9. # 31-bit overflow
  10. i = 1 << 20
  11. print(i * i)
  12. print(i * -i)
  13. print(-i * i)
  14. print(-i * -i)
  15. # 63-bit overflow
  16. i = 1 << 40
  17. print(i * i)
  18. print(i * -i)
  19. print(-i * i)
  20. print(-i * -i)