diff options
Diffstat (limited to 'src/regress/lib/libc/modf/modf_test.c')
| -rw-r--r-- | src/regress/lib/libc/modf/modf_test.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/regress/lib/libc/modf/modf_test.c b/src/regress/lib/libc/modf/modf_test.c new file mode 100644 index 0000000000..f732533635 --- /dev/null +++ b/src/regress/lib/libc/modf/modf_test.c | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | /* Public domain, 2014, Tobias Ulmer <tobiasu@tmux.org> */ | ||
| 2 | |||
| 3 | /* Test for bug introduced in 4.4BSD modf() on sparc */ | ||
| 4 | |||
| 5 | #include <math.h> | ||
| 6 | |||
| 7 | #define BIGFLOAT (5e15) /* Number large enough to trigger the "big" case */ | ||
| 8 | |||
| 9 | int | ||
| 10 | main(void) | ||
| 11 | { | ||
| 12 | double f, i; | ||
| 13 | |||
| 14 | f = modf(BIGFLOAT, &i); | ||
| 15 | if (i != BIGFLOAT) | ||
| 16 | return 1; | ||
| 17 | if (f != 0.0) | ||
| 18 | return 1; | ||
| 19 | |||
| 20 | /* Repeat, maybe we were lucky */ | ||
| 21 | f = modf(BIGFLOAT, &i); | ||
| 22 | if (i != BIGFLOAT) | ||
| 23 | return 1; | ||
| 24 | if (f != 0.0) | ||
| 25 | return 1; | ||
| 26 | |||
| 27 | /* With negative number, for good measure */ | ||
| 28 | f = modf(-BIGFLOAT, &i); | ||
| 29 | if (i != -BIGFLOAT) | ||
| 30 | return 1; | ||
| 31 | if (f != 0.0) | ||
| 32 | return 1; | ||
| 33 | |||
| 34 | return 0; | ||
| 35 | } | ||
