Guest User

Untitled

a guest
Apr 28th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. Cast to union and weird number format
  2. uint64_t flv_dbl2int( double value )
  3. {
  4. return (union {double f; uint64_t i;}){value}.i;
  5. }
  6.  
  7. uint64_t flv_dbl2int(double fvalue)
  8. {
  9. uint64_t ivalue;
  10. memcpy(&ivalue, &fvalue, sizeof ivalue);
  11. return ivalue;
  12. }
  13.  
  14. uint64_t flv_dbl2int(double value)
  15. {
  16. return reinterpret_cast<uint64_t&>(value);
  17. }
  18.  
  19. uint64_t flv_dbl2int( double value )
  20. {
  21. union {double f; uint64_t i;} tmp = { value };
  22. return tmp.i;
  23. }
  24.  
  25. uint64_t flv_dbl2int( double value )
  26. {
  27. return *((uint64_t *) &value);
  28. }
  29.  
  30. uint64_t flv_dbl2int( double value )
  31. {
  32. union Foo {double f; uint64_t i;};
  33. return (*(Foo *)&value).i;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment