fork download
  1. #include <stdio.h>
  2.  
  3. #pragma pack (push, 1)
  4. typedef union FLOAT_VIEW
  5. {
  6. float number;
  7.  
  8. struct
  9. {
  10. unsigned sign : 1;
  11. unsigned order : 8;
  12. unsigned mantiss : 23;
  13. } view;
  14. } FLOAT_VIEW;
  15.  
  16. typedef union DOUBLE_VIEW
  17. {
  18. double number;
  19.  
  20. struct
  21. {
  22. unsigned long long sign : 1;
  23. unsigned long long order : 11;
  24. unsigned long long mantiss : 52;
  25. } view;
  26. } DOUBLE_VIEW;
  27. #pragma pack (pop)
  28.  
  29. void main()
  30. {
  31. printf("sizeof(FLOAT_VIEW) = %d\n", sizeof(FLOAT_VIEW));
  32. printf("sizeof(DOUBLE_VIEW) = %d", sizeof(DOUBLE_VIEW));
  33. }
Runtime error #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
sizeof(FLOAT_VIEW) = 4
sizeof(DOUBLE_VIEW) = 8