fork(10) download
  1. union
  2. {
  3. int i;
  4. float f;
  5. } u;
  6.  
  7. int main()
  8. {
  9. // Convert floating-point bits to integer:
  10. u.f = 3.14159f;
  11. printf("As float: %f\n", u.f);
  12. printf("As integer: %d\n", u.i);
  13. printf("As hex: %08x\n", u.i);
  14.  
  15. return (0);
  16. }
  17.  
Success #stdin #stdout 0s 1832KB
stdin
Standard input is empty
stdout
As float: 3.141590
As integer: 1078530000
As hex: 40490fd0