Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
461 B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. int __cdecl main(int argc, char **argv)
  5. {
  6. unsigned long ul;
  7. float *pf;
  8. if (argc <= 1)
  9. printf("usage: hex2f [32-bit hex number] ==> output is float val\n");
  10. else
  11. {
  12. ul = strtoul(argv[1], 0, 16);
  13. pf = (float *) &ul;
  14. if (*pf == 0.0)
  15. return 0;
  16. if (*pf == -0.0)
  17. return 2;
  18. printf("0x%08lx = %f", ul, *pf);
  19. }
  20. return -1;
  21. }