fork download
  1. #include <stdint.h>
  2. #include <stdio.h>
  3.  
  4. int main(void) {
  5. char myString[]="0xbea78f5d";
  6. uint32_t num;
  7. float f;
  8. sscanf(myString, "%x", &num); // assuming you checked input
  9. f = *((float*)&num);
  10. printf("the hexadecimal 0x%08x becomes %.3f as a float\n", num, f);
  11. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
the hexadecimal 0xbea78f5d becomes -0.327 as a float