1#include "tests/asm.h"
2#include <stdio.h>
3#include <math.h>
4
5double arg, res1, res2;
6
7extern void do_fxtract ( void );
8asm("\n"
9VG_SYM(do_fxtract) ":\n"
10"\tfinit\n"
11"\tfldl " VG_SYM(arg) "\n"
12"\tfxtract\n"
13"\tfstpl " VG_SYM(res1) "\n"
14"\tfstpl " VG_SYM(res2) "\n"
15"\tret"
16);
17
18void try ( double x )
19{
20  arg = x * 1.414213562373049;
21  res1 = res2 = 0.0;
22  do_fxtract();
23  printf("%17.10e  -> %14.10f %14.10f\n", arg, res1, res2);
24}
25
26int main ( void )
27{
28  int i;
29
30  /* positives */
31
32  for (i = 0; i < 40; i++)
33     try( 1.27 + (double)(i*10 - 200) );
34
35  try(+0.0);
36  try(1.0 / 0.0);
37  try(sqrt(-1.0));
38
39  try(5.1e-308);
40  try(4.1e-308);
41  try(3.1e-308);
42  try(2.1e-308);
43  try(1.1e-308);
44  try(0.9e-308);
45  try(0.7e-308);
46  try(0.6e-308);
47  try(0.5e-308);
48  try(0.4e-308);
49  try(0.3e-308);
50  try(0.1e-308);
51
52  try(1.3e-320);
53  try(1.3e-321);
54  try(1.3e-322);
55  try(1.3e-323);
56  try(0.9e-323);
57  try(0.7e-323);
58  try(0.5e-323);
59  try(0.3e-323);
60  try(0.2e-323);
61  try(1.3e-324);
62
63  /* negatives */
64
65  printf("\n");
66  for (i = 0; i < 40; i++)
67     try( - (1.27 + (double)(i*10 - 200)) );
68
69  try(-0.0);
70  try(-(1.0 / 0.0));
71  try(-sqrt(-1.0));
72
73  try(-5.1e-308);
74  try(-4.1e-308);
75  try(-3.1e-308);
76  try(-2.1e-308);
77  try(-1.1e-308);
78  try(-0.9e-308);
79  try(-0.7e-308);
80  try(-0.6e-308);
81  try(-0.5e-308);
82  try(-0.4e-308);
83  try(-0.3e-308);
84  try(-0.1e-308);
85
86  try(-1.3e-320);
87  try(-1.3e-321);
88  try(-1.3e-322);
89  try(-1.3e-323);
90  try(-0.9e-323);
91  try(-0.7e-323);
92  try(-0.5e-323);
93  try(-0.3e-323);
94  try(-0.2e-323);
95  try(-1.3e-324);
96
97  return 0;
98}
99