Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Denormalized float number is detected as NaN. Why?
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int main(void) {
  6.     int i = 0x00300000;
  7.     float f = 0;
  8.     if (sizeof(f) != sizeof(i)) {
  9.         printf ("Urk!n");
  10.         return 1;
  11.     }
  12.     memcpy (&f, &i, sizeof(f));
  13.     printf ("%.50fn", f);
  14.     if (f == f)
  15.         puts ("Equal");
  16.     else
  17.         puts ("Not equal");
  18.     return 0;
  19. }
  20.        
  21. 0.00000000000000000000000000000000000000440810381558
  22. Equal