summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/modf/modf_test.c
blob: f732533635a8cecb77ffaceebcb3afe4dd2f2a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* Public domain, 2014, Tobias Ulmer <tobiasu@tmux.org> */

/* Test for bug introduced in 4.4BSD modf() on sparc */

#include <math.h>

#define BIGFLOAT (5e15) /* Number large enough to trigger the "big" case */

int
main(void)
{
	double f, i;

	f = modf(BIGFLOAT, &i);
	if (i != BIGFLOAT)
		return 1;
	if (f != 0.0)
		return 1;

	/* Repeat, maybe we were lucky */
	f = modf(BIGFLOAT, &i);
	if (i != BIGFLOAT)
		return 1;
	if (f != 0.0)
		return 1;

	/* With negative number, for good measure */
	f = modf(-BIGFLOAT, &i);
	if (i != -BIGFLOAT)
		return 1;
	if (f != 0.0)
		return 1;

	return 0;
}