1
/* Test of fmax() function.
2
$Id: fmax-01.c,v 1.1 2007/02/05 21:35:58 dmix Exp $
14
volatile union lofl_u v = { .lo = 1 };
16
PROGMEM const struct { /* Table of test cases */
17
union lofl_u x, y; /* args */
18
union lofl_u z; /* result */
22
{ { .fl= 0.0 }, { .fl= 0.0 }, { .fl= 0.0 } },
23
{ { .fl= 0.0 }, { .fl= -0.0 }, { .fl= 0.0 } },
24
{ { .fl= -0.0 }, { .fl= -0.0 }, { .fl= -0.0 } },
26
{ { .fl= -0.0 }, { .fl= 0.0 }, { .fl= 0.0 } }, /* Glibc: --> -0.0 */
29
/* fmax (NaN, finite) */
30
{ { 0x7f800001 }, { 0x7f7fffff }, { 0x7f7fffff } },
31
{ { 0x7f800100 }, { 0xff7fffff }, { 0xff7fffff } },
32
{ { 0x7f810000 }, { 0x00000001 }, { 0x00000001 } },
33
{ { 0x7fc00000 }, { 0x80000001 }, { 0x80000001 } },
34
{ { 0x7ffffffe }, { 0x00000000 }, { 0x00000000 } },
35
{ { 0x7fffffff }, { 0x80000000 }, { 0x80000000 } },
37
{ { 0xff800001 }, { 0x7f7fffff }, { 0x7f7fffff } },
38
{ { 0xff800100 }, { 0xff7fffff }, { 0xff7fffff } },
39
{ { 0xff810000 }, { 0x00000001 }, { 0x00000001 } },
40
{ { 0xffc00000 }, { 0x80000001 }, { 0x80000001 } },
41
{ { 0xfffffffe }, { 0x00000000 }, { 0x00000000 } },
42
{ { 0xffffffff }, { 0x80000000 }, { 0x80000000 } },
44
/* fmax (finite, NaN) */
45
{ { 0x7f7fffff }, { 0x7f800001 }, { 0x7f7fffff } },
46
{ { 0xff7fffff }, { 0x7f800100 }, { 0xff7fffff } },
47
{ { 0x00000001 }, { 0x7f810000 }, { 0x00000001 } },
48
{ { 0x80000001 }, { 0x7fc00000 }, { 0x80000001 } },
49
{ { 0x00000000 }, { 0x7ffffffe }, { 0x00000000 } },
50
{ { 0x80000000 }, { 0x7fffffff }, { 0x80000000 } },
52
{ { 0x7f7fffff }, { 0xff800001 }, { 0x7f7fffff } },
53
{ { 0xff7fffff }, { 0xff800100 }, { 0xff7fffff } },
54
{ { 0x00000001 }, { 0xff810000 }, { 0x00000001 } },
55
{ { 0x80000001 }, { 0xffc00000 }, { 0x80000001 } },
56
{ { 0x00000000 }, { 0xfffffffe }, { 0x00000000 } },
57
{ { 0x80000000 }, { 0xffffffff }, { 0x80000000 } },
60
{ { 0x7f800001 }, { 0x7f800000 }, { 0x7f800000 } },
61
{ { 0x7f800001 }, { 0xff800000 }, { 0xff800000 } },
62
{ { 0xff800001 }, { 0x7f800000 }, { 0x7f800000 } },
63
{ { 0xff800001 }, { 0xff800000 }, { 0xff800000 } },
64
{ { 0x7fffffff }, { 0x7f800000 }, { 0x7f800000 } },
65
{ { 0x7fffffff }, { 0xff800000 }, { 0xff800000 } },
66
{ { 0xffffffff }, { 0x7f800000 }, { 0x7f800000 } },
67
{ { 0xffffffff }, { 0xff800000 }, { 0xff800000 } },
70
{ { 0x7f800000 }, { 0x7f800001 }, { 0x7f800000 } },
71
{ { 0xff800000 }, { 0x7f800001 }, { 0xff800000 } },
72
{ { 0x7f800000 }, { 0xff800001 }, { 0x7f800000 } },
73
{ { 0xff800000 }, { 0xff800001 }, { 0xff800000 } },
74
{ { 0x7f800000 }, { 0x7fffffff }, { 0x7f800000 } },
75
{ { 0xff800000 }, { 0x7fffffff }, { 0xff800000 } },
76
{ { 0x7f800000 }, { 0xffffffff }, { 0x7f800000 } },
77
{ { 0xff800000 }, { 0xffffffff }, { 0xff800000 } },
80
{ { 0x7f800001 }, { 0x7fffffff }, { 0x7fffffff } },
81
{ { 0xffffffff }, { 0xff800001 }, { 0xff800001 } },
84
{ { 0x7f800000 }, { 0x7f800000 }, { 0x7f800000 } },
85
{ { 0xff800000 }, { 0x7f800000 }, { 0x7f800000 } },
86
{ { 0x7f800000 }, { 0xff800000 }, { 0x7f800000 } },
87
{ { 0xff800000 }, { 0xff800000 }, { 0xff800000 } },
89
/* fmax (+Inf, finite) */
90
{ { 0x7f800000 }, { 0x7f7fffff }, { 0x7f800000 } },
91
{ { 0x7f800000 }, { 0xff7fffff }, { 0x7f800000 } },
93
/* fmax (-Inf, finite) */
94
{ { 0xff800000 }, { 0x7f7fffff }, { 0x7f7fffff } },
95
{ { 0xff800000 }, { 0xff7fffff }, { 0xff7fffff } },
97
/* fmax (finite, +Inf) */
98
{ { 0x7f7fffff }, { 0x7f800000 }, { 0x7f800000 } },
99
{ { 0xff7fffff }, { 0x7f800000 }, { 0x7f800000 } },
101
/* fmax (finite, -Inf) */
102
{ { 0x7f7fffff }, { 0xff800000 }, { 0x7f7fffff } },
103
{ { 0xff7fffff }, { 0xff800000 }, { 0xff7fffff } },
106
{ { 0x12345678 }, { 0x12345678 }, { 0x12345678 } },
109
{ { 0xff7fffff }, { 0xff7ffffe }, { 0xff7ffffe } },
110
{ { 0x80000002 }, { 0x00000001 }, { 0x00000001 } },
111
{ { 0x7f7ffffe }, { 0x7f7fffff }, { 0x7f7fffff } },
114
{ { 0xff7ffffe }, { 0xff7fffff }, { 0xff7ffffe } },
115
{ { 0x00000000 }, { 0x80000001 }, { 0x00000000 } },
116
{ { 0x7f7fffff }, { 0x7f7ffffe }, { 0x7f7fffff } },
120
void x_exit (int index)
123
fprintf (stderr, "t[%d]: %#lx\n", index - 1, v.lo);
125
exit (index ? index : -1);
133
for (i = 0; i < (int) (sizeof(t) / sizeof(t[0])); i++) {
134
y.lo = pgm_read_dword (& t[i].y);
135
x.lo = pgm_read_dword (& t[i].x);
136
z.lo = pgm_read_dword (& t[i].z);
137
v.fl = fmax (x.fl, y.fl);
140
|| (isnan(v.fl) && isnan(z.fl)) )