fork download
  1. #include <stdio.h>
  2.  
  3. void dump(unsigned char *b)
  4. {
  5. for(int i=0; i<8; ++i) printf(" %02x", *b++);
  6. printf("\n");
  7. }
  8.  
  9. int main()
  10. {
  11. union {
  12. double d;
  13. unsigned char b[8];
  14. } u;
  15. u.d = 0.0;
  16. dump(u.b);
  17. u.d = 1.0;
  18. dump(u.b);
  19. u.d = 0.1;
  20. dump(u.b);
  21. u.d = 0.5;
  22. dump(u.b);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5632KB
stdin
Standard input is empty
stdout
 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 f0 3f
 9a 99 99 99 99 99 b9 3f
 00 00 00 00 00 00 e0 3f