Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- printf("Mapping 100 numbers between 0 and 1 ");
- printf("to their hexadecimal exponential form (HEF).\n");
- printf("Most of them do not equal their HEFs. That means ");
- printf("that their representations as floats ");
- printf("differ from their actual values.\n");
- double f = 0.01;
- int i;
- for (i = 0; i < 100; i++) {
- printf("%1.2f -> %a\n",f*i,f*i);
- }
- printf("Printing 128 'float-compatible' numbers ");
- printf("together with their HEFs for comparison.\n");
- f = 0x1p-7; // ==0.0071825
- for (i = 0; i < 0x80; i++) {
- printf("%1.7f -> %a\n",f*i,f*i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement