Created
February 16, 2013 01:07
-
-
Save boredzo/4964945 to your computer and use it in GitHub Desktop.
Demonstrating properties of hexadecimal floating-point literals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <stdio.h> | |
| int main(int argc, char *argv[]) { | |
| double one = 0x100p-8; | |
| printf("one: %f\n", one); | |
| printf("0x100p-8 == 0x1p+0: %d\n", 0x100p-8 == 0x1p+0); | |
| printf("0x100p-8 == 1.0: %d\n", 0x100p-8 == 1.0); | |
| double n = 0xe5p-8, d = 0xffp-8; | |
| printf("%f/%f = %f\n", n, d, n/d); | |
| return EXIT_SUCCESS; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment