]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/floatformat.c
* config/i386/darwin.h (DBX_REGISTER_NUMBER): Define.
[thirdparty/gcc.git] / libiberty / floatformat.c
CommitLineData
6599da04 1/* IEEE floating point support routines, for GDB, the GNU Debugger.
e89b6c1c
MK
2 Copyright 1991, 1994, 1999, 2000, 2003, 2005
3 Free Software Foundation, Inc.
6599da04
JM
4
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
ee58dffd 19Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
6599da04 20
bee6ab3e
ILT
21/* This is needed to pick up the NAN macro on some systems. */
22#define _GNU_SOURCE
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28#include <math.h>
29
30#ifdef HAVE_STRING_H
31#include <string.h>
32#endif
33
c9ac9147 34#include "ansidecl.h"
bee6ab3e 35#include "libiberty.h"
6599da04 36#include "floatformat.h"
bee6ab3e
ILT
37
38#ifndef INFINITY
39#ifdef HUGE_VAL
40#define INFINITY HUGE_VAL
6599da04 41#else
bee6ab3e
ILT
42#define INFINITY (1.0 / 0.0)
43#endif
44#endif
45
46#ifndef NAN
47#define NAN (0.0 / 0.0)
6599da04
JM
48#endif
49
6da879de
GDR
50static unsigned long get_field (const unsigned char *,
51 enum floatformat_byteorders,
52 unsigned int,
53 unsigned int,
54 unsigned int);
55static int floatformat_always_valid (const struct floatformat *fmt,
e89b6c1c 56 const void *from);
83c07342
AC
57
58static int
6da879de 59floatformat_always_valid (const struct floatformat *fmt ATTRIBUTE_UNUSED,
e89b6c1c 60 const void *from ATTRIBUTE_UNUSED)
83c07342
AC
61{
62 return 1;
63}
64
6599da04
JM
65/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not
66 going to bother with trying to muck around with whether it is defined in
67 a system header, what we do if not, etc. */
68#define FLOATFORMAT_CHAR_BIT 8
69
70/* floatformats for IEEE single and double, big and little endian. */
71const struct floatformat floatformat_ieee_single_big =
72{
0b72c3df
AC
73 floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23,
74 floatformat_intbit_no,
83c07342
AC
75 "floatformat_ieee_single_big",
76 floatformat_always_valid
6599da04
JM
77};
78const struct floatformat floatformat_ieee_single_little =
79{
0b72c3df
AC
80 floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23,
81 floatformat_intbit_no,
83c07342
AC
82 "floatformat_ieee_single_little",
83 floatformat_always_valid
6599da04
JM
84};
85const struct floatformat floatformat_ieee_double_big =
86{
0b72c3df
AC
87 floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52,
88 floatformat_intbit_no,
83c07342
AC
89 "floatformat_ieee_double_big",
90 floatformat_always_valid
6599da04
JM
91};
92const struct floatformat floatformat_ieee_double_little =
93{
0b72c3df
AC
94 floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52,
95 floatformat_intbit_no,
83c07342
AC
96 "floatformat_ieee_double_little",
97 floatformat_always_valid
6599da04
JM
98};
99
100/* floatformat for IEEE double, little endian byte order, with big endian word
101 ordering, as on the ARM. */
102
103const struct floatformat floatformat_ieee_double_littlebyte_bigword =
104{
0b72c3df
AC
105 floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52,
106 floatformat_intbit_no,
83c07342
AC
107 "floatformat_ieee_double_littlebyte_bigword",
108 floatformat_always_valid
6599da04
JM
109};
110
0432a5de
MK
111/* floatformat for VAX. Not quite IEEE, but close enough. */
112
113const struct floatformat floatformat_vax_f =
114{
115 floatformat_vax, 32, 0, 1, 8, 129, 0, 9, 23,
116 floatformat_intbit_no,
117 "floatformat_vax_f",
118 floatformat_always_valid
119};
120const struct floatformat floatformat_vax_d =
121{
122 floatformat_vax, 64, 0, 1, 8, 129, 0, 9, 55,
123 floatformat_intbit_no,
124 "floatformat_vax_d",
125 floatformat_always_valid
126};
127const struct floatformat floatformat_vax_g =
128{
129 floatformat_vax, 64, 0, 1, 11, 1025, 0, 12, 52,
130 floatformat_intbit_no,
131 "floatformat_vax_g",
132 floatformat_always_valid
133};
134
e89b6c1c
MK
135static int floatformat_i387_ext_is_valid (const struct floatformat *fmt,
136 const void *from);
83c07342
AC
137
138static int
e89b6c1c 139floatformat_i387_ext_is_valid (const struct floatformat *fmt, const void *from)
83c07342
AC
140{
141 /* In the i387 double-extended format, if the exponent is all ones,
142 then the integer bit must be set. If the exponent is neither 0
143 nor ~0, the intbit must also be set. Only if the exponent is
144 zero can it be zero, and then it must be zero. */
145 unsigned long exponent, int_bit;
573b07c7 146 const unsigned char *ufrom = (const unsigned char *) from;
e89b6c1c 147
83c07342
AC
148 exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
149 fmt->exp_start, fmt->exp_len);
150 int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize,
151 fmt->man_start, 1);
e89b6c1c 152
83c07342
AC
153 if ((exponent == 0) != (int_bit == 0))
154 return 0;
155 else
156 return 1;
157}
158
6599da04
JM
159const struct floatformat floatformat_i387_ext =
160{
161 floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
0b72c3df 162 floatformat_intbit_yes,
83c07342
AC
163 "floatformat_i387_ext",
164 floatformat_i387_ext_is_valid
6599da04
JM
165};
166const struct floatformat floatformat_m68881_ext =
167{
168 /* Note that the bits from 16 to 31 are unused. */
0b72c3df
AC
169 floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64,
170 floatformat_intbit_yes,
83c07342
AC
171 "floatformat_m68881_ext",
172 floatformat_always_valid
6599da04
JM
173};
174const struct floatformat floatformat_i960_ext =
175{
176 /* Note that the bits from 0 to 15 are unused. */
177 floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
0b72c3df 178 floatformat_intbit_yes,
83c07342
AC
179 "floatformat_i960_ext",
180 floatformat_always_valid
6599da04
JM
181};
182const struct floatformat floatformat_m88110_ext =
183{
0310e5ac
AC
184 floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
185 floatformat_intbit_yes,
83c07342
AC
186 "floatformat_m88110_ext",
187 floatformat_always_valid
0310e5ac
AC
188};
189const struct floatformat floatformat_m88110_harris_ext =
190{
6599da04
JM
191 /* Harris uses raw format 128 bytes long, but the number is just an ieee
192 double, and the last 64 bits are wasted. */
193 floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52,
0b72c3df 194 floatformat_intbit_no,
83c07342
AC
195 "floatformat_m88110_ext_harris",
196 floatformat_always_valid
6599da04 197};
0310e5ac
AC
198const struct floatformat floatformat_arm_ext_big =
199{
200 /* Bits 1 to 16 are unused. */
201 floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
202 floatformat_intbit_yes,
83c07342
AC
203 "floatformat_arm_ext_big",
204 floatformat_always_valid
0310e5ac
AC
205};
206const struct floatformat floatformat_arm_ext_littlebyte_bigword =
207{
208 /* Bits 1 to 16 are unused. */
209 floatformat_littlebyte_bigword, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
210 floatformat_intbit_yes,
83c07342
AC
211 "floatformat_arm_ext_littlebyte_bigword",
212 floatformat_always_valid
0310e5ac
AC
213};
214const struct floatformat floatformat_ia64_spill_big =
215{
216 floatformat_big, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
217 floatformat_intbit_yes,
83c07342
AC
218 "floatformat_ia64_spill_big",
219 floatformat_always_valid
0310e5ac
AC
220};
221const struct floatformat floatformat_ia64_spill_little =
222{
223 floatformat_little, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
224 floatformat_intbit_yes,
83c07342
AC
225 "floatformat_ia64_spill_little",
226 floatformat_always_valid
0310e5ac
AC
227};
228const struct floatformat floatformat_ia64_quad_big =
229{
230 floatformat_big, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
231 floatformat_intbit_no,
83c07342
AC
232 "floatformat_ia64_quad_big",
233 floatformat_always_valid
0310e5ac
AC
234};
235const struct floatformat floatformat_ia64_quad_little =
236{
237 floatformat_little, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
238 floatformat_intbit_no,
83c07342
AC
239 "floatformat_ia64_quad_little",
240 floatformat_always_valid
0310e5ac 241};
6599da04 242\f
9c8860c3 243/* Extract a field which starts at START and is LEN bits long. DATA and
6599da04
JM
244 TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
245static unsigned long
6da879de
GDR
246get_field (const unsigned char *data, enum floatformat_byteorders order,
247 unsigned int total_len, unsigned int start, unsigned int len)
6599da04
JM
248{
249 unsigned long result;
250 unsigned int cur_byte;
251 int cur_bitshift;
252
253 /* Start at the least significant part of the field. */
254 cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT;
255 if (order == floatformat_little)
256 cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1;
257 cur_bitshift =
258 ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT;
259 result = *(data + cur_byte) >> (-cur_bitshift);
260 cur_bitshift += FLOATFORMAT_CHAR_BIT;
261 if (order == floatformat_little)
262 ++cur_byte;
263 else
264 --cur_byte;
265
266 /* Move towards the most significant part of the field. */
5ad5a984 267 while ((unsigned int) cur_bitshift < len)
6599da04
JM
268 {
269 if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
270 /* This is the last byte; zero out the bits which are not part of
271 this field. */
272 result |=
273 (*(data + cur_byte) & ((1 << (len - cur_bitshift)) - 1))
274 << cur_bitshift;
275 else
276 result |= *(data + cur_byte) << cur_bitshift;
277 cur_bitshift += FLOATFORMAT_CHAR_BIT;
278 if (order == floatformat_little)
279 ++cur_byte;
280 else
281 --cur_byte;
282 }
283 return result;
284}
285
286#ifndef min
287#define min(a, b) ((a) < (b) ? (a) : (b))
288#endif
289
290/* Convert from FMT to a double.
291 FROM is the address of the extended float.
292 Store the double in *TO. */
293
294void
6da879de 295floatformat_to_double (const struct floatformat *fmt,
e89b6c1c 296 const void *from, double *to)
6599da04 297{
573b07c7 298 const unsigned char *ufrom = (const unsigned char *) from;
6599da04
JM
299 double dto;
300 long exponent;
301 unsigned long mant;
302 unsigned int mant_bits, mant_off;
303 int mant_bits_left;
304 int special_exponent; /* It's a NaN, denorm or zero */
305
306 exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
307 fmt->exp_start, fmt->exp_len);
bee6ab3e
ILT
308
309 /* If the exponent indicates a NaN, we don't have information to
310 decide what to do. So we handle it like IEEE, except that we
311 don't try to preserve the type of NaN. FIXME. */
312 if ((unsigned long) exponent == fmt->exp_nan)
313 {
314 int nan;
315
316 mant_off = fmt->man_start;
317 mant_bits_left = fmt->man_len;
318 nan = 0;
319 while (mant_bits_left > 0)
320 {
321 mant_bits = min (mant_bits_left, 32);
322
323 if (get_field (ufrom, fmt->byteorder, fmt->totalsize,
324 mant_off, mant_bits) != 0)
325 {
326 /* This is a NaN. */
327 nan = 1;
328 break;
329 }
330
331 mant_off += mant_bits;
332 mant_bits_left -= mant_bits;
333 }
334
72f93778
BE
335 /* On certain systems (such as GNU/Linux), the use of the
336 INFINITY macro below may generate a warning that can not be
337 silenced due to a bug in GCC (PR preprocessor/11931). The
338 preprocessor fails to recognise the __extension__ keyword in
339 conjunction with the GNU/C99 extension for hexadecimal
340 floating point constants and will issue a warning when
341 compiling with -pedantic. */
bee6ab3e
ILT
342 if (nan)
343 dto = NAN;
344 else
345 dto = INFINITY;
346
347 if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
348 dto = -dto;
349
350 *to = dto;
351
352 return;
353 }
6599da04
JM
354
355 mant_bits_left = fmt->man_len;
356 mant_off = fmt->man_start;
357 dto = 0.0;
358
5ad5a984 359 special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan;
6599da04
JM
360
361 /* Don't bias zero's, denorms or NaNs. */
362 if (!special_exponent)
363 exponent -= fmt->exp_bias;
364
365 /* Build the result algebraically. Might go infinite, underflow, etc;
366 who cares. */
367
368 /* If this format uses a hidden bit, explicitly add it in now. Otherwise,
369 increment the exponent by one to account for the integer bit. */
370
371 if (!special_exponent)
087aa398
KG
372 {
373 if (fmt->intbit == floatformat_intbit_no)
374 dto = ldexp (1.0, exponent);
375 else
376 exponent++;
377 }
6599da04
JM
378
379 while (mant_bits_left > 0)
380 {
381 mant_bits = min (mant_bits_left, 32);
382
383 mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
384 mant_off, mant_bits);
385
bee6ab3e
ILT
386 /* Handle denormalized numbers. FIXME: What should we do for
387 non-IEEE formats? */
388 if (exponent == 0 && mant != 0)
389 dto += ldexp ((double)mant,
390 (- fmt->exp_bias
391 - mant_bits
392 - (mant_off - fmt->man_start)
393 + 1));
394 else
395 dto += ldexp ((double)mant, exponent - mant_bits);
396 if (exponent != 0)
397 exponent -= mant_bits;
6599da04
JM
398 mant_off += mant_bits;
399 mant_bits_left -= mant_bits;
400 }
401
402 /* Negate it if negative. */
403 if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
404 dto = -dto;
405 *to = dto;
406}
407\f
6da879de
GDR
408static void put_field (unsigned char *, enum floatformat_byteorders,
409 unsigned int,
410 unsigned int,
411 unsigned int,
412 unsigned long);
6599da04 413
9c8860c3 414/* Set a field which starts at START and is LEN bits long. DATA and
6599da04
JM
415 TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
416static void
6da879de
GDR
417put_field (unsigned char *data, enum floatformat_byteorders order,
418 unsigned int total_len, unsigned int start, unsigned int len,
419 unsigned long stuff_to_put)
6599da04
JM
420{
421 unsigned int cur_byte;
422 int cur_bitshift;
423
424 /* Start at the least significant part of the field. */
425 cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT;
426 if (order == floatformat_little)
427 cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1;
428 cur_bitshift =
429 ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT;
430 *(data + cur_byte) &=
431 ~(((1 << ((start + len) % FLOATFORMAT_CHAR_BIT)) - 1) << (-cur_bitshift));
432 *(data + cur_byte) |=
433 (stuff_to_put & ((1 << FLOATFORMAT_CHAR_BIT) - 1)) << (-cur_bitshift);
434 cur_bitshift += FLOATFORMAT_CHAR_BIT;
435 if (order == floatformat_little)
436 ++cur_byte;
437 else
438 --cur_byte;
439
440 /* Move towards the most significant part of the field. */
5ad5a984 441 while ((unsigned int) cur_bitshift < len)
6599da04
JM
442 {
443 if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
444 {
445 /* This is the last byte. */
446 *(data + cur_byte) &=
447 ~((1 << (len - cur_bitshift)) - 1);
448 *(data + cur_byte) |= (stuff_to_put >> cur_bitshift);
449 }
450 else
451 *(data + cur_byte) = ((stuff_to_put >> cur_bitshift)
452 & ((1 << FLOATFORMAT_CHAR_BIT) - 1));
453 cur_bitshift += FLOATFORMAT_CHAR_BIT;
454 if (order == floatformat_little)
455 ++cur_byte;
456 else
457 --cur_byte;
458 }
459}
460
461/* The converse: convert the double *FROM to an extended float
462 and store where TO points. Neither FROM nor TO have any alignment
463 restrictions. */
464
465void
6da879de 466floatformat_from_double (const struct floatformat *fmt,
e89b6c1c 467 const double *from, void *to)
6599da04
JM
468{
469 double dfrom;
470 int exponent;
471 double mant;
472 unsigned int mant_bits, mant_off;
473 int mant_bits_left;
573b07c7 474 unsigned char *uto = (unsigned char *) to;
6599da04 475
bee6ab3e 476 dfrom = *from;
6599da04 477 memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);
bee6ab3e
ILT
478
479 /* If negative, set the sign bit. */
480 if (dfrom < 0)
481 {
482 put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1);
483 dfrom = -dfrom;
484 }
485
6599da04 486 if (dfrom == 0)
bee6ab3e
ILT
487 {
488 /* 0.0. */
489 return;
490 }
491
6599da04
JM
492 if (dfrom != dfrom)
493 {
bee6ab3e 494 /* NaN. */
6599da04
JM
495 put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
496 fmt->exp_len, fmt->exp_nan);
bee6ab3e 497 /* Be sure it's not infinity, but NaN value is irrelevant. */
6599da04
JM
498 put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start,
499 32, 1);
500 return;
501 }
502
bee6ab3e 503 if (dfrom + dfrom == dfrom)
6599da04 504 {
bee6ab3e
ILT
505 /* This can only happen for an infinite value (or zero, which we
506 already handled above). */
507 put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
508 fmt->exp_len, fmt->exp_nan);
509 return;
6599da04
JM
510 }
511
6599da04 512 mant = frexp (dfrom, &exponent);
bee6ab3e
ILT
513 if (exponent + fmt->exp_bias - 1 > 0)
514 put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
515 fmt->exp_len, exponent + fmt->exp_bias - 1);
516 else
517 {
518 /* Handle a denormalized number. FIXME: What should we do for
519 non-IEEE formats? */
520 put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
521 fmt->exp_len, 0);
522 mant = ldexp (mant, exponent + fmt->exp_bias - 1);
523 }
6599da04
JM
524
525 mant_bits_left = fmt->man_len;
526 mant_off = fmt->man_start;
527 while (mant_bits_left > 0)
528 {
529 unsigned long mant_long;
530 mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
531
532 mant *= 4294967296.0;
533 mant_long = (unsigned long)mant;
534 mant -= mant_long;
535
bee6ab3e
ILT
536 /* If the integer bit is implicit, and we are not creating a
537 denormalized number, then we need to discard it. */
5ad5a984 538 if ((unsigned int) mant_bits_left == fmt->man_len
bee6ab3e
ILT
539 && fmt->intbit == floatformat_intbit_no
540 && exponent + fmt->exp_bias - 1 > 0)
6599da04
JM
541 {
542 mant_long &= 0x7fffffff;
543 mant_bits -= 1;
544 }
545 else if (mant_bits < 32)
546 {
547 /* The bits we want are in the most significant MANT_BITS bits of
548 mant_long. Move them to the least significant. */
549 mant_long >>= 32 - mant_bits;
550 }
551
552 put_field (uto, fmt->byteorder, fmt->totalsize,
553 mant_off, mant_bits, mant_long);
554 mant_off += mant_bits;
555 mant_bits_left -= mant_bits;
556 }
557}
558
9c8860c3
DJ
559/* Return non-zero iff the data at FROM is a valid number in format FMT. */
560
561int
e89b6c1c 562floatformat_is_valid (const struct floatformat *fmt, const void *from)
9c8860c3 563{
83c07342 564 return fmt->is_valid (fmt, from);
9c8860c3
DJ
565}
566
6599da04
JM
567
568#ifdef IEEE_DEBUG
569
bee6ab3e
ILT
570#include <stdio.h>
571
6599da04
JM
572/* This is to be run on a host which uses IEEE floating point. */
573
574void
6da879de 575ieee_test (double n)
6599da04
JM
576{
577 double result;
6599da04 578
e89b6c1c 579 floatformat_to_double (&floatformat_ieee_double_little, &n, &result);
bee6ab3e
ILT
580 if ((n != result && (! isnan (n) || ! isnan (result)))
581 || (n < 0 && result >= 0)
582 || (n >= 0 && result < 0))
6599da04 583 printf ("Differ(to): %.20g -> %.20g\n", n, result);
bee6ab3e 584
e89b6c1c 585 floatformat_from_double (&floatformat_ieee_double_little, &n, &result);
bee6ab3e
ILT
586 if ((n != result && (! isnan (n) || ! isnan (result)))
587 || (n < 0 && result >= 0)
588 || (n >= 0 && result < 0))
6599da04
JM
589 printf ("Differ(from): %.20g -> %.20g\n", n, result);
590
bee6ab3e
ILT
591#if 0
592 {
593 char exten[16];
594
595 floatformat_from_double (&floatformat_m68881_ext, &n, exten);
596 floatformat_to_double (&floatformat_m68881_ext, exten, &result);
597 if (n != result)
598 printf ("Differ(to+from): %.20g -> %.20g\n", n, result);
599 }
600#endif
6599da04
JM
601
602#if IEEE_DEBUG > 1
603 /* This is to be run on a host which uses 68881 format. */
604 {
605 long double ex = *(long double *)exten;
606 if (ex != n)
607 printf ("Differ(from vs. extended): %.20g\n", n);
608 }
609#endif
610}
611
612int
6da879de 613main (void)
6599da04 614{
bee6ab3e 615 ieee_test (0.0);
6599da04
JM
616 ieee_test (0.5);
617 ieee_test (256.0);
618 ieee_test (0.12345);
619 ieee_test (234235.78907234);
620 ieee_test (-512.0);
621 ieee_test (-0.004321);
bee6ab3e
ILT
622 ieee_test (1.2E-70);
623 ieee_test (1.2E-316);
624 ieee_test (4.9406564584124654E-324);
625 ieee_test (- 4.9406564584124654E-324);
626 ieee_test (- 0.0);
627 ieee_test (- INFINITY);
628 ieee_test (- NAN);
629 ieee_test (INFINITY);
630 ieee_test (NAN);
6599da04
JM
631 return 0;
632}
633#endif