-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ subprojects/zlib-* | |
.DS_Store | ||
test/sizeof | ||
temp/* | ||
|
||
test/test_convert |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* test how conversions of integers to doubles affects the values */ | ||
|
||
|
||
#include <stdio.h> | ||
#include <stdint.h> | ||
|
||
int main(int argc, char** argv){ | ||
|
||
int64_t nSec = 60L*60*24*( 365*55 + 13); /* rough seconds in 55 years */ | ||
printf("64-Bit Int seconds in ~55 years %ld\n", nSec); | ||
|
||
double dSec = (double)nSec; | ||
printf("Double seconds in ~55 years %f\n", dSec); | ||
|
||
int64_t nNano = nSec * 1000000000 + 11111; | ||
printf("64-Bit Int nanoseconds in ~55 years %ld\n", nNano); | ||
|
||
double dNano = (double)nNano; | ||
|
||
printf("Double nanoseconds in ~55 years %f\n", dNano); | ||
|
||
printf("\nPrecision loss is about 100 nanosec @ 50 years.\n"); | ||
} |