Guest User

Untitled

a guest
Jun 25th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. double offset = pow(2, (i >> 20) - 0x3ff) * (((i & 0xfffff) + 0x100000) / (double) 0x100000);
  2.  
  3. >>> def IntFromReal32(i):
  4. exponent = (i >> 20) - 0x3ff
  5. mantissa = (i & 0xfffff) + 0x100000
  6. return mantissa >> (20 - exponent)
  7.  
  8. >>> testdata = range(0x40000000,0x40240000,0x10000) + range(0x40800000,0x40830000,0x10000) + [1088631936]
  9. >>> from datetime import date,timedelta
  10. >>> for i in testdata:
  11. print "0x%08x" % i, date(1899,12,30) + timedelta(IntFromReal32(i))
  12.  
  13.  
  14. 0x40000000 1900-01-01
  15. 0x40010000 1900-01-01
  16. 0x40020000 1900-01-01
  17. 0x40030000 1900-01-01
  18. 0x40040000 1900-01-01
  19. 0x40050000 1900-01-01
  20. 0x40060000 1900-01-01
  21. 0x40070000 1900-01-01
  22. 0x40080000 1900-01-02
  23. 0x40090000 1900-01-02
  24. 0x400a0000 1900-01-02
  25. 0x400b0000 1900-01-02
  26. 0x400c0000 1900-01-02
  27. 0x400d0000 1900-01-02
  28. 0x400e0000 1900-01-02
  29. 0x400f0000 1900-01-02
  30. 0x40100000 1900-01-03
  31. 0x40110000 1900-01-03
  32. 0x40120000 1900-01-03
  33. 0x40130000 1900-01-03
  34. 0x40140000 1900-01-04
  35. 0x40150000 1900-01-04
  36. 0x40160000 1900-01-04
  37. 0x40170000 1900-01-04
  38. 0x40180000 1900-01-05
  39. 0x40190000 1900-01-05
  40. 0x401a0000 1900-01-05
  41. 0x401b0000 1900-01-05
  42. 0x401c0000 1900-01-06
  43. 0x401d0000 1900-01-06
  44. 0x401e0000 1900-01-06
  45. 0x401f0000 1900-01-06
  46. 0x40200000 1900-01-07
  47. 0x40210000 1900-01-07
  48. 0x40220000 1900-01-08
  49. 0x40230000 1900-01-08
  50. 0x40800000 1901-05-26
  51. 0x40810000 1901-06-27
  52. 0x40820000 1901-07-29
  53. 0x40e33480 2007-09-07
  54.  
  55. In [8]: time.strftime("%s", (2009, 3, 21, 1, 1, 0, 0,0,0))
  56. Out[8]: '1237590060'
  57.  
  58. In [9]: time.strftime("%s", (2009, 3, 22, 1, 1, 0, 0,0,0))
  59. Out[9]: '1237676460'
  60.  
  61. In [10]: print("%0x %0x" % (1237590060, 1237676460))
  62. 49c4202c 49c571ac
  63.  
  64. date time abw xtr dbcap avabw avxtr avdbcap rtt timestamp
  65. 06/30/04 14:43:48 1.000 0.000 1.100 1.042 0.003 1.095 384.387 1088631828
  66. 06/30/04 14:45:36 1.100 0.000 1.100 1.051 0.003 1.096 376.408 1088631936
  67. 06/30/04 14:47:23 1.000 0.000 1.100 1.043 0.003 1.097 375.196 1088632043
Add Comment
Please, Sign In to add comment