No empty .Rs/.Re
[netbsd-mini2440.git] / regress / lib / libc / ldexp / ldexp.c
blob3777483799c584d2fe4a93af8d31f40b002eb9a2
1 /* $NetBSD: ldexp.c,v 1.3 2006/05/10 19:07:22 mrg Exp $ */
3 /*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <math.h>
30 #include <stdio.h>
31 #include <stdlib.h>
33 int
34 main()
36 double v;
37 int e;
39 #define FORMAT "%23.23lg\n"
41 printf("basics:\n");
42 v = 1.0; e = 5;
43 printf(FORMAT, ldexp(v, e));
44 v = 1.0; e = 1022;
45 printf(FORMAT, ldexp(v, e));
46 v = ldexp(1.0, 1023); e = -1;
47 printf(FORMAT, ldexp(v, e));
48 v = 1.0; e = 1023;
49 printf(FORMAT, ldexp(v, e));
50 v = ldexp(1.0, 1022); e = 1;
51 printf(FORMAT, ldexp(v, e));
52 v = ldexp(1.0, -1022); e = 2045;
53 printf(FORMAT, ldexp(v, e));
54 v = 1.0; e = -5;
55 printf(FORMAT, ldexp(v, e));
56 v = 1.0; e = -1021;
57 printf(FORMAT, ldexp(v, e));
58 v = ldexp(1.0, -1022); e = 1;
59 printf(FORMAT, ldexp(v, e));
60 v = 1.0; e = -1022;
61 printf(FORMAT, ldexp(v, e));
62 v = ldexp(1.0, -1021); e = -1;
63 printf(FORMAT, ldexp(v, e));
64 v = ldexp(1.0, 1023); e = -2045;
65 printf(FORMAT, ldexp(v, e));
66 v = ldexp(1.0, 1023); e = -1023;
67 printf(FORMAT, ldexp(v, e));
68 v = ldexp(1.0, -1022); e = 1022;
69 printf(FORMAT, ldexp(v, e));
70 printf("\n");
72 printf("zero:\n");
73 v = 0.0; e = -1;
74 printf(FORMAT, ldexp(v, e));
75 v = 0.0; e = 0;
76 printf(FORMAT, ldexp(v, e));
77 v = 0.0; e = 1;
78 printf(FORMAT, ldexp(v, e));
79 v = 0.0; e = 1024;
80 printf(FORMAT, ldexp(v, e));
81 v = 0.0; e = 1025;
82 printf(FORMAT, ldexp(v, e));
83 v = 0.0; e = -1023;
84 printf(FORMAT, ldexp(v, e));
85 v = 0.0; e = -1024;
86 printf(FORMAT, ldexp(v, e));
87 printf("\n");
89 printf("infinity:\n");
90 v = ldexp(1.0, 1024); e = -1;
91 printf(FORMAT, ldexp(v, e));
92 v = ldexp(1.0, 1024); e = 0;
93 printf(FORMAT, ldexp(v, e));
94 v = ldexp(1.0, 1024); e = 1;
95 printf(FORMAT, ldexp(v, e));
96 v = ldexp(-1.0, 1024); e = -1;
97 printf(FORMAT, ldexp(v, e));
98 v = ldexp(-1.0, 1024); e = 0;
99 printf(FORMAT, ldexp(v, e));
100 v = ldexp(-1.0, 1024); e = 1;
101 printf(FORMAT, ldexp(v, e));
102 printf("\n");
104 printf("overflow:\n");
105 v = 1.0; e = 1024;
106 printf(FORMAT, ldexp(v, e));
107 v = ldexp(1.0, 1023); e = 1;
108 printf(FORMAT, ldexp(v, e));
109 v = ldexp(1.0, -1022); e = 2046;
110 printf(FORMAT, ldexp(v, e));
111 v = 1.0; e = 1025;
112 printf(FORMAT, ldexp(v, e));
113 v = -1.0; e = 1024;
114 printf(FORMAT, ldexp(v, e));
115 v = ldexp(-1.0, 1023); e = 1;
116 printf(FORMAT, ldexp(v, e));
117 v = ldexp(-1.0, -1022); e = 2046;
118 printf(FORMAT, ldexp(v, e));
119 v = -1.0; e = 1025;
120 printf(FORMAT, ldexp(v, e));
121 printf("\n");
123 printf("denormal:\n");
124 v = 1.0; e = -1023;
125 printf(FORMAT, ldexp(v, e));
126 v = ldexp(1.0, -1022); e = -1;
127 printf(FORMAT, ldexp(v, e));
128 v = ldexp(1.0, 1023); e = -2046;
129 printf(FORMAT, ldexp(v, e));
130 v = 1.0; e = -1024;
131 printf(FORMAT, ldexp(v, e));
132 v = 1.0; e = -1074;
133 printf(FORMAT, ldexp(v, e));
134 v = -1.0; e = -1023;
135 printf(FORMAT, ldexp(v, e));
136 v = ldexp(-1.0, -1022); e = -1;
137 printf(FORMAT, ldexp(v, e));
138 v = ldexp(-1.0, 1023); e = -2046;
139 printf(FORMAT, ldexp(v, e));
140 v = -1.0; e = -1024;
141 printf(FORMAT, ldexp(v, e));
142 v = -1.0; e = -1074;
143 printf(FORMAT, ldexp(v, e));
144 printf("\n");
146 printf("underflow:\n");
147 v = 1.0; e = -1075;
148 printf(FORMAT, ldexp(v, e));
149 v = ldexp(1.0, -1074); e = -1;
150 printf(FORMAT, ldexp(v, e));
151 v = ldexp(1.0, 1023); e = -2098;
152 printf(FORMAT, ldexp(v, e));
153 v = 1.0; e = -1076;
154 printf(FORMAT, ldexp(v, e));
155 v = -1.0; e = -1075;
156 printf(FORMAT, ldexp(v, e));
157 v = ldexp(-1.0, -1074); e = -1;
158 printf(FORMAT, ldexp(v, e));
159 v = ldexp(-1.0, 1023); e = -2098;
160 printf(FORMAT, ldexp(v, e));
161 v = -1.0; e = -1076;
162 printf(FORMAT, ldexp(v, e));
163 printf("\n");
165 printf("denormal, large exponent:\n");
166 v = ldexp(1.0, -1028); e = 1024;
167 printf(FORMAT, ldexp(v, e));
168 v = ldexp(1.0, -1028); e = 1025;
169 printf(FORMAT, ldexp(v, e));
170 v = ldexp(1.0, -1028); e = 1026;
171 printf(FORMAT, ldexp(v, e));
172 v = ldexp(1.0, -1028); e = 1027;
173 printf(FORMAT, ldexp(v, e));
174 v = ldexp(1.0, -1028); e = 1028;
175 printf(FORMAT, ldexp(v, e));
176 v = ldexp(1.0, -1028); e = 1029;
177 printf(FORMAT, ldexp(v, e));
178 v = ldexp(1.0, -1028); e = 1030;
179 printf(FORMAT, ldexp(v, e));
180 v = ldexp(1.0, -1028); e = 1040;
181 printf(FORMAT, ldexp(v, e));
182 v = ldexp(1.0, -1028); e = 1050;
183 printf(FORMAT, ldexp(v, e));
184 v = ldexp(1.0, -1028); e = 1060;
185 printf(FORMAT, ldexp(v, e));
186 v = ldexp(1.0, -1028); e = 1100;
187 printf(FORMAT, ldexp(v, e));
188 v = ldexp(1.0, -1028); e = 1200;
189 printf(FORMAT, ldexp(v, e));
190 v = ldexp(1.0, -1028); e = 1300;
191 printf(FORMAT, ldexp(v, e));
192 v = ldexp(1.0, -1028); e = 1400;
193 printf(FORMAT, ldexp(v, e));
194 v = ldexp(1.0, -1028); e = 1500;
195 printf(FORMAT, ldexp(v, e));
196 v = ldexp(1.0, -1028); e = 1600;
197 printf(FORMAT, ldexp(v, e));
198 v = ldexp(1.0, -1028); e = 1700;
199 printf(FORMAT, ldexp(v, e));
200 v = ldexp(1.0, -1028); e = 1800;
201 printf(FORMAT, ldexp(v, e));
202 v = ldexp(1.0, -1028); e = 1900;
203 printf(FORMAT, ldexp(v, e));
204 v = ldexp(1.0, -1028); e = 2000;
205 printf(FORMAT, ldexp(v, e));
206 v = ldexp(1.0, -1028); e = 2046;
207 printf(FORMAT, ldexp(v, e));
208 v = ldexp(1.0, -1028); e = 2047;
209 printf(FORMAT, ldexp(v, e));
210 v = ldexp(1.0, -1028); e = 2048;
211 printf(FORMAT, ldexp(v, e));
212 v = ldexp(1.0, -1028); e = 2049;
213 printf(FORMAT, ldexp(v, e));
214 v = ldexp(1.0, -1028); e = 2050;
215 printf(FORMAT, ldexp(v, e));
216 v = ldexp(1.0, -1028); e = 2051;
217 printf(FORMAT, ldexp(v, e));
219 exit(0);