Does float in Linux gcc (5.4.0) obey IEEE754 rules?

Viewed 718

My programming environment is gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

I code like:

#include <stdio.h>

typedef unsigned char *byte_pointer;

void show_bytes(byte_pointer start, int len){
  int i;
  for (i = 0; i<len; i++)
    printf(" %.2x", start[i]);
  printf("\n");
}

void show_float(float x){
  show_bytes((byte_pointer)&x, sizeof(float));
}

int main(){
  int y = 0xffffff;
  float f = y;
  show_float(f);
  return 0;
}

and the machine give the result: 00 00 00 e0

I think it is not right according to IEEE 754; but i don't know why. while the same code in VS 2013 in windows give the right answer: ff ff 7f 4b

Does gcc 5.4.0 not adopt the IEEE 754? Or are there some problem in my code?

2 Answers
Related