builtin_float_hash.py 426 B

12345678910111213141516171819202122232425
  1. # test builtin hash function with float args
  2. # these should hash to an integer with a specific value
  3. for val in (
  4. '0.0',
  5. '-0.0',
  6. '1.0',
  7. '2.0',
  8. '-12.0',
  9. '12345.0',
  10. ):
  11. print(val, hash(float(val)))
  12. # just check that these values are hashable
  13. for val in (
  14. '0.1',
  15. '-0.1',
  16. '10.3',
  17. '0.4e3',
  18. '1e16',
  19. 'inf',
  20. '-inf',
  21. 'nan',
  22. ):
  23. print(val, type(hash(float(val))))