Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     printf("Mapping 100 numbers between 0 and 1 ");
  6.     printf("to their hexadecimal exponential form (HEF).\n");
  7.     printf("Most of them do not equal their HEFs. That means ");
  8.     printf("that their representations as floats ");
  9.     printf("differ from their actual values.\n");
  10.     double f = 0.01;
  11.     int i;
  12.     for (i = 0; i < 100; i++) {
  13.        printf("%1.2f -> %a\n",f*i,f*i);
  14.     }
  15.     printf("Printing 128 'float-compatible' numbers ");
  16.     printf("together with their HEFs for comparison.\n");
  17.     f = 0x1p-7; // ==0.0071825
  18.     for (i = 0; i < 0x80; i++) {
  19.        printf("%1.7f -> %a\n",f*i,f*i);
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement