1
/* Test of addition. Rounding.
2
$Id: add-03.c,v 1.1 2007/02/05 21:35:58 dmix Exp $
13
volatile union lofl_u v = { .lo = 1 };
15
PROGMEM const struct { /* Table of test cases: x + y = z */
19
/* The remainder is exactly 0.5: look the smart rounding direction. */
20
{ { .fl = 0x0.8p0 }, { .fl = 0x0.0000008p0 }, { .fl = 0x0.800000p0 } },
21
{ { .fl = 0x0.8p0 }, { .fl = 0x0.0000010p0 }, { .fl = 0x0.800001p0 } },
22
{ { .fl = 0x0.8p0 }, { .fl = 0x0.0000018p0 }, { .fl = 0x0.800002p0 } },
23
{ { .fl = 0x0.8p0 }, { .fl = 0x0.0000020p0 }, { .fl = 0x0.800002p0 } },
24
{ { .fl = 0x0.8p0 }, { .fl = 0x0.0000028p0 }, { .fl = 0x0.800002p0 } },
25
{ { .fl = 0x0.8p0 }, { .fl = 0x0.0000030p0 }, { .fl = 0x0.800003p0 } },
26
{ { .fl = 0x0.8p0 }, { .fl = 0x0.0000038p0 }, { .fl = 0x0.800004p0 } },
27
{ { .fl = 0x0.8p0 }, { .fl = 0x0.0000040p0 }, { .fl = 0x0.800004p0 } },
29
/* The remainder is exactly 0.5, subtraction. */
30
{ { .fl = 0x0.9p0 }, { .fl = -0x0.0000008p0 }, { .fl = 0x0.900000p0 } },
31
{ { .fl = 0x0.9p0 }, { .fl = -0x0.0000010p0 }, { .fl = 0x0.8fffffp0 } },
32
{ { .fl = 0x0.9p0 }, { .fl = -0x0.0000018p0 }, { .fl = 0x0.8ffffep0 } },
33
{ { .fl = 0x0.9p0 }, { .fl = -0x0.0000020p0 }, { .fl = 0x0.8ffffep0 } },
34
{ { .fl = 0x0.9p0 }, { .fl = -0x0.0000028p0 }, { .fl = 0x0.8ffffep0 } },
35
{ { .fl = 0x0.9p0 }, { .fl = -0x0.0000030p0 }, { .fl = 0x0.8ffffdp0 } },
36
{ { .fl = 0x0.9p0 }, { .fl = -0x0.0000038p0 }, { .fl = 0x0.8ffffcp0 } },
37
{ { .fl = 0x0.9p0 }, { .fl = -0x0.0000040p0 }, { .fl = 0x0.8ffffcp0 } },
41
void x_exit (int index)
44
fprintf (stderr, "t[%d]: %#lx\n", index - 1, v.lo);
46
exit (index ? index : -1);
54
for (i = 0; i < (int) (sizeof(t) / sizeof(t[0])); i++) {
55
x.lo = pgm_read_dword (& t[i].x);
56
y.lo = pgm_read_dword (& t[i].y);
57
z.lo = pgm_read_dword (& t[i].z);
59
/* Comparison is integer to verify the zero sign. */