1 /* real.c - implementation of REAL_ARITHMETIC, REAL_VALUE_ATOF,
2 and support for XFmode IEEE extended real floating point arithmetic.
3 Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
4 Contributed by Stephen L. Moshier (moshier@world.std.com).
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
32 /* To enable support of XFmode extended real floating point, define
33 LONG_DOUBLE_TYPE_SIZE 96 in the tm.h file (m68k.h or i386.h).
35 To support cross compilation between IEEE, VAX and IBM floating
36 point formats, define REAL_ARITHMETIC in the tm.h file.
38 In either case the machine files (tm.h) must not contain any code
39 that tries to use host floating point arithmetic to convert
40 REAL_VALUE_TYPEs from `double' to `float', pass them to fprintf,
41 etc. In cross-compile situations a REAL_VALUE_TYPE may not
42 be intelligible to the host computer's native arithmetic.
44 The emulator defaults to the host's floating point format so that
45 its decimal conversion functions can be used if desired (see
48 The first part of this file interfaces gcc to a floating point
49 arithmetic suite that was not written with gcc in mind. Avoid
50 changing the low-level arithmetic routines unless you have suitable
51 test programs available. A special version of the PARANOIA floating
52 point arithmetic tester, modified for this purpose, can be found on
53 usc.edu: /pub/C-numanal/ieeetest.zoo. Other tests, and libraries of
54 XFmode and TFmode transcendental functions, can be obtained by ftp from
55 netlib.att.com: netlib/cephes. */
57 /* Type of computer arithmetic.
58 Only one of DEC, IBM, IEEE, or UNK should get defined.
60 `IEEE', when REAL_WORDS_BIG_ENDIAN is non-zero, refers generically
61 to big-endian IEEE floating-point data structure. This definition
62 should work in SFmode `float' type and DFmode `double' type on
63 virtually all big-endian IEEE machines. If LONG_DOUBLE_TYPE_SIZE
64 has been defined to be 96, then IEEE also invokes the particular
65 XFmode (`long double' type) data structure used by the Motorola
66 680x0 series processors.
68 `IEEE', when REAL_WORDS_BIG_ENDIAN is zero, refers generally to
69 little-endian IEEE machines. In this case, if LONG_DOUBLE_TYPE_SIZE
70 has been defined to be 96, then IEEE also invokes the particular
71 XFmode `long double' data structure used by the Intel 80x86 series
74 `DEC' refers specifically to the Digital Equipment Corp PDP-11
75 and VAX floating point data structure. This model currently
76 supports no type wider than DFmode.
78 `IBM' refers specifically to the IBM System/370 and compatible
79 floating point data structure. This model currently supports
80 no type wider than DFmode. The IBM conversions were contributed by
81 frank@atom.ansto.gov.au (Frank Crawford).
83 If LONG_DOUBLE_TYPE_SIZE = 64 (the default, unless tm.h defines it)
84 then `long double' and `double' are both implemented, but they
85 both mean DFmode. In this case, the software floating-point
86 support available here is activated by writing
87 #define REAL_ARITHMETIC
90 The case LONG_DOUBLE_TYPE_SIZE = 128 activates TFmode support
91 and may deactivate XFmode since `long double' is used to refer
94 The macros FLOAT_WORDS_BIG_ENDIAN, HOST_FLOAT_WORDS_BIG_ENDIAN,
95 contributed by Richard Earnshaw <Richard.Earnshaw@cl.cam.ac.uk>,
96 separate the floating point unit's endian-ness from that of
97 the integer addressing. This permits one to define a big-endian
98 FPU on a little-endian machine (e.g., ARM). An extension to
99 BYTES_BIG_ENDIAN may be required for some machines in the future.
100 These optional macros may be defined in tm.h. In real.h, they
101 default to WORDS_BIG_ENDIAN, etc., so there is no need to define
102 them for any normal host or target machine on which the floats
103 and the integers have the same endian-ness. */
106 /* The following converts gcc macros into the ones used by this file. */
108 /* REAL_ARITHMETIC defined means that macros in real.h are
109 defined to call emulator functions. */
110 #ifdef REAL_ARITHMETIC
112 #if TARGET_FLOAT_FORMAT == VAX_FLOAT_FORMAT
113 /* PDP-11, Pro350, VAX: */
115 #else /* it's not VAX */
116 #if TARGET_FLOAT_FORMAT == IBM_FLOAT_FORMAT
117 /* IBM System/370 style */
119 #else /* it's also not an IBM */
120 #if TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
122 #else /* it's not IEEE either */
123 /* UNKnown arithmetic. We don't support this and can't go on. */
124 unknown arithmetic type
126 #endif /* not IEEE */
130 #define REAL_WORDS_BIG_ENDIAN FLOAT_WORDS_BIG_ENDIAN
133 /* REAL_ARITHMETIC not defined means that the *host's* data
134 structure will be used. It may differ by endian-ness from the
135 target machine's structure and will get its ends swapped
136 accordingly (but not here). Probably only the decimal <-> binary
137 functions in this file will actually be used in this case. */
139 #if HOST_FLOAT_FORMAT == VAX_FLOAT_FORMAT
141 #else /* it's not VAX */
142 #if HOST_FLOAT_FORMAT == IBM_FLOAT_FORMAT
143 /* IBM System/370 style */
145 #else /* it's also not an IBM */
146 #if HOST_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
148 #else /* it's not IEEE either */
149 unknown arithmetic type
151 #endif /* not IEEE */
155 #define REAL_WORDS_BIG_ENDIAN HOST_FLOAT_WORDS_BIG_ENDIAN
157 #endif /* REAL_ARITHMETIC not defined */
159 /* Define INFINITY for support of infinity.
160 Define NANS for support of Not-a-Number's (NaN's). */
161 #if !defined(DEC) && !defined(IBM)
166 /* Support of NaNs requires support of infinity. */
173 /* Find a host integer type that is at least 16 bits wide,
174 and another type at least twice whatever that size is. */
176 #if HOST_BITS_PER_CHAR >= 16
177 #define EMUSHORT char
178 #define EMUSHORT_SIZE HOST_BITS_PER_CHAR
179 #define EMULONG_SIZE (2 * HOST_BITS_PER_CHAR)
181 #if HOST_BITS_PER_SHORT >= 16
182 #define EMUSHORT short
183 #define EMUSHORT_SIZE HOST_BITS_PER_SHORT
184 #define EMULONG_SIZE (2 * HOST_BITS_PER_SHORT)
186 #if HOST_BITS_PER_INT >= 16
188 #define EMUSHORT_SIZE HOST_BITS_PER_INT
189 #define EMULONG_SIZE (2 * HOST_BITS_PER_INT)
191 #if HOST_BITS_PER_LONG >= 16
192 #define EMUSHORT long
193 #define EMUSHORT_SIZE HOST_BITS_PER_LONG
194 #define EMULONG_SIZE (2 * HOST_BITS_PER_LONG)
196 /* You will have to modify this program to have a smaller unit size. */
197 #define EMU_NON_COMPILE
203 #if HOST_BITS_PER_SHORT >= EMULONG_SIZE
204 #define EMULONG short
206 #if HOST_BITS_PER_INT >= EMULONG_SIZE
209 #if HOST_BITS_PER_LONG >= EMULONG_SIZE
212 #if HOST_BITS_PER_LONG_LONG >= EMULONG_SIZE
213 #define EMULONG long long int
215 /* You will have to modify this program to have a smaller unit size. */
216 #define EMU_NON_COMPILE
223 /* The host interface doesn't work if no 16-bit size exists. */
224 #if EMUSHORT_SIZE != 16
225 #define EMU_NON_COMPILE
228 /* OK to continue compilation. */
229 #ifndef EMU_NON_COMPILE
231 /* Construct macros to translate between REAL_VALUE_TYPE and e type.
232 In GET_REAL and PUT_REAL, r and e are pointers.
233 A REAL_VALUE_TYPE is guaranteed to occupy contiguous locations
234 in memory, with no holes. */
236 #if LONG_DOUBLE_TYPE_SIZE == 96
237 /* Number of 16 bit words in external e type format */
239 #define MAXDECEXP 4932
240 #define MINDECEXP -4956
241 #define GET_REAL(r,e) bcopy ((char *) r, (char *) e, 2*NE)
242 #define PUT_REAL(e,r) bcopy ((char *) e, (char *) r, 2*NE)
243 #else /* no XFmode */
244 #if LONG_DOUBLE_TYPE_SIZE == 128
246 #define MAXDECEXP 4932
247 #define MINDECEXP -4977
248 #define GET_REAL(r,e) bcopy ((char *) r, (char *) e, 2*NE)
249 #define PUT_REAL(e,r) bcopy ((char *) e, (char *) r, 2*NE)
252 #define MAXDECEXP 4932
253 #define MINDECEXP -4956
254 #ifdef REAL_ARITHMETIC
255 /* Emulator uses target format internally
256 but host stores it in host endian-ness. */
258 #define GET_REAL(r,e) \
260 if (HOST_FLOAT_WORDS_BIG_ENDIAN == REAL_WORDS_BIG_ENDIAN) \
261 e53toe ((unsigned EMUSHORT *) (r), (e)); \
264 unsigned EMUSHORT w[4]; \
265 w[3] = ((EMUSHORT *) r)[0]; \
266 w[2] = ((EMUSHORT *) r)[1]; \
267 w[1] = ((EMUSHORT *) r)[2]; \
268 w[0] = ((EMUSHORT *) r)[3]; \
273 #define PUT_REAL(e,r) \
275 if (HOST_FLOAT_WORDS_BIG_ENDIAN == REAL_WORDS_BIG_ENDIAN) \
276 etoe53 ((e), (unsigned EMUSHORT *) (r)); \
279 unsigned EMUSHORT w[4]; \
281 *((EMUSHORT *) r) = w[3]; \
282 *((EMUSHORT *) r + 1) = w[2]; \
283 *((EMUSHORT *) r + 2) = w[1]; \
284 *((EMUSHORT *) r + 3) = w[0]; \
288 #else /* not REAL_ARITHMETIC */
290 /* emulator uses host format */
291 #define GET_REAL(r,e) e53toe ((unsigned EMUSHORT *) (r), (e))
292 #define PUT_REAL(e,r) etoe53 ((e), (unsigned EMUSHORT *) (r))
294 #endif /* not REAL_ARITHMETIC */
295 #endif /* not TFmode */
296 #endif /* no XFmode */
299 /* Number of 16 bit words in internal format */
302 /* Array offset to exponent */
305 /* Array offset to high guard word */
308 /* Number of bits of precision */
309 #define NBITS ((NI-4)*16)
311 /* Maximum number of decimal digits in ASCII conversion
314 #define NDEC (NBITS*8/27)
316 /* The exponent of 1.0 */
317 #define EXONE (0x3fff)
319 extern int extra_warnings
;
320 extern unsigned EMUSHORT ezero
[], ehalf
[], eone
[], etwo
[];
321 extern unsigned EMUSHORT elog2
[], esqrt2
[];
323 static void endian
PROTO((unsigned EMUSHORT
*, long *,
325 static void eclear
PROTO((unsigned EMUSHORT
*));
326 static void emov
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
327 static void eabs
PROTO((unsigned EMUSHORT
*));
328 static void eneg
PROTO((unsigned EMUSHORT
*));
329 static int eisneg
PROTO((unsigned EMUSHORT
*));
330 static int eisinf
PROTO((unsigned EMUSHORT
*));
331 static int eisnan
PROTO((unsigned EMUSHORT
*));
332 static void einfin
PROTO((unsigned EMUSHORT
*));
333 static void enan
PROTO((unsigned EMUSHORT
*, int));
334 static void emovi
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
335 static void emovo
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
336 static void ecleaz
PROTO((unsigned EMUSHORT
*));
337 static void ecleazs
PROTO((unsigned EMUSHORT
*));
338 static void emovz
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
339 static void einan
PROTO((unsigned EMUSHORT
*));
340 static int eiisnan
PROTO((unsigned EMUSHORT
*));
341 static int eiisneg
PROTO((unsigned EMUSHORT
*));
342 static void eiinfin
PROTO((unsigned EMUSHORT
*));
343 static int eiisinf
PROTO((unsigned EMUSHORT
*));
344 static int ecmpm
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
345 static void eshdn1
PROTO((unsigned EMUSHORT
*));
346 static void eshup1
PROTO((unsigned EMUSHORT
*));
347 static void eshdn8
PROTO((unsigned EMUSHORT
*));
348 static void eshup8
PROTO((unsigned EMUSHORT
*));
349 static void eshup6
PROTO((unsigned EMUSHORT
*));
350 static void eshdn6
PROTO((unsigned EMUSHORT
*));
351 static void eaddm
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));\f
352 static void esubm
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
353 static void m16m
PROTO((unsigned int, unsigned short *,
355 static int edivm
PROTO((unsigned short *, unsigned short *));
356 static int emulm
PROTO((unsigned short *, unsigned short *));
357 static void emdnorm
PROTO((unsigned EMUSHORT
*, int, int, EMULONG
, int));
358 static void esub
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
359 unsigned EMUSHORT
*));
360 static void eadd
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
361 unsigned EMUSHORT
*));
362 static void eadd1
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
363 unsigned EMUSHORT
*));
364 static void ediv
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
365 unsigned EMUSHORT
*));
366 static void emul
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
367 unsigned EMUSHORT
*));
368 static void e53toe
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
369 static void e64toe
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
370 static void e113toe
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
371 static void e24toe
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
372 static void etoe113
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
373 static void toe113
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
374 static void etoe64
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
375 static void toe64
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
376 static void etoe53
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
377 static void toe53
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
378 static void etoe24
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
379 static void toe24
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
380 static int ecmp
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
381 static void eround
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
382 static void ltoe
PROTO((HOST_WIDE_INT
*, unsigned EMUSHORT
*));
383 static void ultoe
PROTO((unsigned HOST_WIDE_INT
*, unsigned EMUSHORT
*));
384 static void eifrac
PROTO((unsigned EMUSHORT
*, HOST_WIDE_INT
*,
385 unsigned EMUSHORT
*));
386 static void euifrac
PROTO((unsigned EMUSHORT
*, unsigned HOST_WIDE_INT
*,
387 unsigned EMUSHORT
*));
388 static int eshift
PROTO((unsigned EMUSHORT
*, int));
389 static int enormlz
PROTO((unsigned EMUSHORT
*));
390 static void e24toasc
PROTO((unsigned EMUSHORT
*, char *, int));
391 static void e53toasc
PROTO((unsigned EMUSHORT
*, char *, int));
392 static void e64toasc
PROTO((unsigned EMUSHORT
*, char *, int));
393 static void e113toasc
PROTO((unsigned EMUSHORT
*, char *, int));
394 static void etoasc
PROTO((unsigned EMUSHORT
*, char *, int));
395 static void asctoe24
PROTO((char *, unsigned EMUSHORT
*));
396 static void asctoe53
PROTO((char *, unsigned EMUSHORT
*));
397 static void asctoe64
PROTO((char *, unsigned EMUSHORT
*));
398 static void asctoe113
PROTO((char *, unsigned EMUSHORT
*));
399 static void asctoe
PROTO((char *, unsigned EMUSHORT
*));
400 static void asctoeg
PROTO((char *, unsigned EMUSHORT
*, int));
401 static void efloor
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
402 static void efrexp
PROTO((unsigned EMUSHORT
*, int *,
403 unsigned EMUSHORT
*));
404 static void eldexp
PROTO((unsigned EMUSHORT
*, int, unsigned EMUSHORT
*));
405 static void eremain
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
406 unsigned EMUSHORT
*));
407 static void eiremain
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
408 static void mtherr
PROTO((char *, int));
409 static void dectoe
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
410 static void etodec
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
411 static void todec
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
412 static void ibmtoe
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
414 static void etoibm
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
416 static void toibm
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*,
418 static void make_nan
PROTO((unsigned EMUSHORT
*, int, enum machine_mode
));
419 static void uditoe
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
420 static void ditoe
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
421 static void etoudi
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
422 static void etodi
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
423 static void esqrt
PROTO((unsigned EMUSHORT
*, unsigned EMUSHORT
*));
425 /* Copy 32-bit numbers obtained from array containing 16-bit numbers,
426 swapping ends if required, into output array of longs. The
427 result is normally passed to fprintf by the ASM_OUTPUT_ macros. */
431 unsigned EMUSHORT e
[];
433 enum machine_mode mode
;
437 if (REAL_WORDS_BIG_ENDIAN
)
443 /* Swap halfwords in the fourth long. */
444 th
= (unsigned long) e
[6] & 0xffff;
445 t
= (unsigned long) e
[7] & 0xffff;
451 /* Swap halfwords in the third long. */
452 th
= (unsigned long) e
[4] & 0xffff;
453 t
= (unsigned long) e
[5] & 0xffff;
456 /* fall into the double case */
460 /* swap halfwords in the second word */
461 th
= (unsigned long) e
[2] & 0xffff;
462 t
= (unsigned long) e
[3] & 0xffff;
465 /* fall into the float case */
470 /* swap halfwords in the first word */
471 th
= (unsigned long) e
[0] & 0xffff;
472 t
= (unsigned long) e
[1] & 0xffff;
483 /* Pack the output array without swapping. */
490 /* Pack the fourth long. */
491 th
= (unsigned long) e
[7] & 0xffff;
492 t
= (unsigned long) e
[6] & 0xffff;
498 /* Pack the third long.
499 Each element of the input REAL_VALUE_TYPE array has 16 useful bits
501 th
= (unsigned long) e
[5] & 0xffff;
502 t
= (unsigned long) e
[4] & 0xffff;
505 /* fall into the double case */
509 /* pack the second long */
510 th
= (unsigned long) e
[3] & 0xffff;
511 t
= (unsigned long) e
[2] & 0xffff;
514 /* fall into the float case */
519 /* pack the first long */
520 th
= (unsigned long) e
[1] & 0xffff;
521 t
= (unsigned long) e
[0] & 0xffff;
533 /* This is the implementation of the REAL_ARITHMETIC macro. */
536 earith (value
, icode
, r1
, r2
)
537 REAL_VALUE_TYPE
*value
;
542 unsigned EMUSHORT d1
[NE
], d2
[NE
], v
[NE
];
548 /* Return NaN input back to the caller. */
551 PUT_REAL (d1
, value
);
556 PUT_REAL (d2
, value
);
560 code
= (enum tree_code
) icode
;
568 esub (d2
, d1
, v
); /* d1 - d2 */
576 #ifndef REAL_INFINITY
577 if (ecmp (d2
, ezero
) == 0)
580 enan (v
, eisneg (d1
) ^ eisneg (d2
));
587 ediv (d2
, d1
, v
); /* d1/d2 */
590 case MIN_EXPR
: /* min (d1,d2) */
591 if (ecmp (d1
, d2
) < 0)
597 case MAX_EXPR
: /* max (d1,d2) */
598 if (ecmp (d1
, d2
) > 0)
611 /* Truncate REAL_VALUE_TYPE toward zero to signed HOST_WIDE_INT.
612 implements REAL_VALUE_RNDZINT (x) (etrunci (x)). */
618 unsigned EMUSHORT f
[NE
], g
[NE
];
634 /* Truncate REAL_VALUE_TYPE toward zero to unsigned HOST_WIDE_INT;
635 implements REAL_VALUE_UNSIGNED_RNDZINT (x) (etruncui (x)). */
641 unsigned EMUSHORT f
[NE
], g
[NE
];
643 unsigned HOST_WIDE_INT l
;
657 /* This is the REAL_VALUE_ATOF function. It converts a decimal string to
658 binary, rounding off as indicated by the machine_mode argument. Then it
659 promotes the rounded value to REAL_VALUE_TYPE. */
666 unsigned EMUSHORT tem
[NE
], e
[NE
];
696 /* Expansion of REAL_NEGATE. */
702 unsigned EMUSHORT e
[NE
];
712 /* Round real toward zero to HOST_WIDE_INT;
713 implements REAL_VALUE_FIX (x). */
719 unsigned EMUSHORT f
[NE
], g
[NE
];
726 warning ("conversion from NaN to int");
734 /* Round real toward zero to unsigned HOST_WIDE_INT
735 implements REAL_VALUE_UNSIGNED_FIX (x).
736 Negative input returns zero. */
738 unsigned HOST_WIDE_INT
742 unsigned EMUSHORT f
[NE
], g
[NE
];
743 unsigned HOST_WIDE_INT l
;
749 warning ("conversion from NaN to unsigned int");
758 /* REAL_VALUE_FROM_INT macro. */
761 ereal_from_int (d
, i
, j
, mode
)
764 enum machine_mode mode
;
766 unsigned EMUSHORT df
[NE
], dg
[NE
];
767 HOST_WIDE_INT low
, high
;
770 if (GET_MODE_CLASS (mode
) != MODE_FLOAT
)
777 /* complement and add 1 */
784 eldexp (eone
, HOST_BITS_PER_WIDE_INT
, df
);
785 ultoe ((unsigned HOST_WIDE_INT
*) &high
, dg
);
787 ultoe ((unsigned HOST_WIDE_INT
*) &low
, df
);
792 /* A REAL_VALUE_TYPE may not be wide enough to hold the two HOST_WIDE_INTS.
793 Avoid double-rounding errors later by rounding off now from the
794 extra-wide internal format to the requested precision. */
795 switch (GET_MODE_BITSIZE (mode
))
825 /* REAL_VALUE_FROM_UNSIGNED_INT macro. */
828 ereal_from_uint (d
, i
, j
, mode
)
830 unsigned HOST_WIDE_INT i
, j
;
831 enum machine_mode mode
;
833 unsigned EMUSHORT df
[NE
], dg
[NE
];
834 unsigned HOST_WIDE_INT low
, high
;
836 if (GET_MODE_CLASS (mode
) != MODE_FLOAT
)
840 eldexp (eone
, HOST_BITS_PER_WIDE_INT
, df
);
846 /* A REAL_VALUE_TYPE may not be wide enough to hold the two HOST_WIDE_INTS.
847 Avoid double-rounding errors later by rounding off now from the
848 extra-wide internal format to the requested precision. */
849 switch (GET_MODE_BITSIZE (mode
))
879 /* REAL_VALUE_TO_INT macro. */
882 ereal_to_int (low
, high
, rr
)
883 HOST_WIDE_INT
*low
, *high
;
886 unsigned EMUSHORT d
[NE
], df
[NE
], dg
[NE
], dh
[NE
];
893 warning ("conversion from NaN to int");
899 /* convert positive value */
906 eldexp (eone
, HOST_BITS_PER_WIDE_INT
, df
);
907 ediv (df
, d
, dg
); /* dg = d / 2^32 is the high word */
908 euifrac (dg
, (unsigned HOST_WIDE_INT
*) high
, dh
);
909 emul (df
, dh
, dg
); /* fractional part is the low word */
910 euifrac (dg
, (unsigned HOST_WIDE_INT
*)low
, dh
);
913 /* complement and add 1 */
923 /* REAL_VALUE_LDEXP macro. */
930 unsigned EMUSHORT e
[NE
], y
[NE
];
943 /* These routines are conditionally compiled because functions
944 of the same names may be defined in fold-const.c. */
946 #ifdef REAL_ARITHMETIC
948 /* Check for infinity in a REAL_VALUE_TYPE. */
954 unsigned EMUSHORT e
[NE
];
964 /* Check whether a REAL_VALUE_TYPE item is a NaN. */
970 unsigned EMUSHORT e
[NE
];
981 /* Check for a negative REAL_VALUE_TYPE number.
982 This just checks the sign bit, so that -0 counts as negative. */
988 return ereal_isneg (x
);
991 /* Expansion of REAL_VALUE_TRUNCATE.
992 The result is in floating point, rounded to nearest or even. */
995 real_value_truncate (mode
, arg
)
996 enum machine_mode mode
;
999 unsigned EMUSHORT e
[NE
], t
[NE
];
1035 /* If an unsupported type was requested, presume that
1036 the machine files know something useful to do with
1037 the unmodified value. */
1046 /* Try to change R into its exact multiplicative inverse in machine mode
1047 MODE. Return nonzero function value if successful. */
1050 exact_real_inverse (mode
, r
)
1051 enum machine_mode mode
;
1054 unsigned EMUSHORT e
[NE
], einv
[NE
];
1055 REAL_VALUE_TYPE rinv
;
1060 /* Test for input in range. Don't transform IEEE special values. */
1061 if (eisinf (e
) || eisnan (e
) || (ecmp (e
, ezero
) == 0))
1064 /* Test for a power of 2: all significand bits zero except the MSB.
1065 We are assuming the target has binary (or hex) arithmetic. */
1066 if (e
[NE
- 2] != 0x8000)
1069 for (i
= 0; i
< NE
- 2; i
++)
1075 /* Compute the inverse and truncate it to the required mode. */
1076 ediv (e
, eone
, einv
);
1077 PUT_REAL (einv
, &rinv
);
1078 rinv
= real_value_truncate (mode
, rinv
);
1080 #ifdef CHECK_FLOAT_VALUE
1081 /* This check is not redundant. It may, for example, flush
1082 a supposedly IEEE denormal value to zero. */
1084 if (CHECK_FLOAT_VALUE (mode
, rinv
, i
))
1087 GET_REAL (&rinv
, einv
);
1089 /* Check the bits again, because the truncation might have
1090 generated an arbitrary saturation value on overflow. */
1091 if (einv
[NE
- 2] != 0x8000)
1094 for (i
= 0; i
< NE
- 2; i
++)
1100 /* Fail if the computed inverse is out of range. */
1101 if (eisinf (einv
) || eisnan (einv
) || (ecmp (einv
, ezero
) == 0))
1104 /* Output the reciprocal and return success flag. */
1108 #endif /* REAL_ARITHMETIC defined */
1110 /* Used for debugging--print the value of R in human-readable format
1119 REAL_VALUE_TO_DECIMAL (r
, "%.20g", dstr
);
1120 fprintf (stderr
, "%s", dstr
);
1124 /* The following routines convert REAL_VALUE_TYPE to the various floating
1125 point formats that are meaningful to supported computers.
1127 The results are returned in 32-bit pieces, each piece stored in a `long'.
1128 This is so they can be printed by statements like
1130 fprintf (file, "%lx, %lx", L[0], L[1]);
1132 that will work on both narrow- and wide-word host computers. */
1134 /* Convert R to a 128-bit long double precision value. The output array L
1135 contains four 32-bit pieces of the result, in the order they would appear
1143 unsigned EMUSHORT e
[NE
];
1147 endian (e
, l
, TFmode
);
1150 /* Convert R to a double extended precision value. The output array L
1151 contains three 32-bit pieces of the result, in the order they would
1152 appear in memory. */
1159 unsigned EMUSHORT e
[NE
];
1163 endian (e
, l
, XFmode
);
1166 /* Convert R to a double precision value. The output array L contains two
1167 32-bit pieces of the result, in the order they would appear in memory. */
1174 unsigned EMUSHORT e
[NE
];
1178 endian (e
, l
, DFmode
);
1181 /* Convert R to a single precision float value stored in the least-significant
1182 bits of a `long'. */
1188 unsigned EMUSHORT e
[NE
];
1193 endian (e
, &l
, SFmode
);
1197 /* Convert X to a decimal ASCII string S for output to an assembly
1198 language file. Note, there is no standard way to spell infinity or
1199 a NaN, so these values may require special treatment in the tm.h
1203 ereal_to_decimal (x
, s
)
1207 unsigned EMUSHORT e
[NE
];
1213 /* Compare X and Y. Return 1 if X > Y, 0 if X == Y, -1 if X < Y,
1214 or -2 if either is a NaN. */
1218 REAL_VALUE_TYPE x
, y
;
1220 unsigned EMUSHORT ex
[NE
], ey
[NE
];
1224 return (ecmp (ex
, ey
));
1227 /* Return 1 if the sign bit of X is set, else return 0. */
1233 unsigned EMUSHORT ex
[NE
];
1236 return (eisneg (ex
));
1239 /* End of REAL_ARITHMETIC interface */
1242 Extended precision IEEE binary floating point arithmetic routines
1244 Numbers are stored in C language as arrays of 16-bit unsigned
1245 short integers. The arguments of the routines are pointers to
1248 External e type data structure, similar to Intel 8087 chip
1249 temporary real format but possibly with a larger significand:
1251 NE-1 significand words (least significant word first,
1252 most significant bit is normally set)
1253 exponent (value = EXONE for 1.0,
1254 top bit is the sign)
1257 Internal exploded e-type data structure of a number (a "word" is 16 bits):
1259 ei[0] sign word (0 for positive, 0xffff for negative)
1260 ei[1] biased exponent (value = EXONE for the number 1.0)
1261 ei[2] high guard word (always zero after normalization)
1263 to ei[NI-2] significand (NI-4 significand words,
1264 most significant word first,
1265 most significant bit is set)
1266 ei[NI-1] low guard word (0x8000 bit is rounding place)
1270 Routines for external format e-type numbers
1272 asctoe (string, e) ASCII string to extended double e type
1273 asctoe64 (string, &d) ASCII string to long double
1274 asctoe53 (string, &d) ASCII string to double
1275 asctoe24 (string, &f) ASCII string to single
1276 asctoeg (string, e, prec) ASCII string to specified precision
1277 e24toe (&f, e) IEEE single precision to e type
1278 e53toe (&d, e) IEEE double precision to e type
1279 e64toe (&d, e) IEEE long double precision to e type
1280 e113toe (&d, e) 128-bit long double precision to e type
1281 eabs (e) absolute value
1282 eadd (a, b, c) c = b + a
1284 ecmp (a, b) Returns 1 if a > b, 0 if a == b,
1285 -1 if a < b, -2 if either a or b is a NaN.
1286 ediv (a, b, c) c = b / a
1287 efloor (a, b) truncate to integer, toward -infinity
1288 efrexp (a, exp, s) extract exponent and significand
1289 eifrac (e, &l, frac) e to HOST_WIDE_INT and e type fraction
1290 euifrac (e, &l, frac) e to unsigned HOST_WIDE_INT and e type fraction
1291 einfin (e) set e to infinity, leaving its sign alone
1292 eldexp (a, n, b) multiply by 2**n
1294 emul (a, b, c) c = b * a
1296 eround (a, b) b = nearest integer value to a
1297 esub (a, b, c) c = b - a
1298 e24toasc (&f, str, n) single to ASCII string, n digits after decimal
1299 e53toasc (&d, str, n) double to ASCII string, n digits after decimal
1300 e64toasc (&d, str, n) 80-bit long double to ASCII string
1301 e113toasc (&d, str, n) 128-bit long double to ASCII string
1302 etoasc (e, str, n) e to ASCII string, n digits after decimal
1303 etoe24 (e, &f) convert e type to IEEE single precision
1304 etoe53 (e, &d) convert e type to IEEE double precision
1305 etoe64 (e, &d) convert e type to IEEE long double precision
1306 ltoe (&l, e) HOST_WIDE_INT to e type
1307 ultoe (&l, e) unsigned HOST_WIDE_INT to e type
1308 eisneg (e) 1 if sign bit of e != 0, else 0
1309 eisinf (e) 1 if e has maximum exponent (non-IEEE)
1310 or is infinite (IEEE)
1311 eisnan (e) 1 if e is a NaN
1314 Routines for internal format exploded e-type numbers
1316 eaddm (ai, bi) add significands, bi = bi + ai
1318 ecleazs (ei) set ei = 0 but leave its sign alone
1319 ecmpm (ai, bi) compare significands, return 1, 0, or -1
1320 edivm (ai, bi) divide significands, bi = bi / ai
1321 emdnorm (ai,l,s,exp) normalize and round off
1322 emovi (a, ai) convert external a to internal ai
1323 emovo (ai, a) convert internal ai to external a
1324 emovz (ai, bi) bi = ai, low guard word of bi = 0
1325 emulm (ai, bi) multiply significands, bi = bi * ai
1326 enormlz (ei) left-justify the significand
1327 eshdn1 (ai) shift significand and guards down 1 bit
1328 eshdn8 (ai) shift down 8 bits
1329 eshdn6 (ai) shift down 16 bits
1330 eshift (ai, n) shift ai n bits up (or down if n < 0)
1331 eshup1 (ai) shift significand and guards up 1 bit
1332 eshup8 (ai) shift up 8 bits
1333 eshup6 (ai) shift up 16 bits
1334 esubm (ai, bi) subtract significands, bi = bi - ai
1335 eiisinf (ai) 1 if infinite
1336 eiisnan (ai) 1 if a NaN
1337 eiisneg (ai) 1 if sign bit of ai != 0, else 0
1338 einan (ai) set ai = NaN
1339 eiinfin (ai) set ai = infinity
1341 The result is always normalized and rounded to NI-4 word precision
1342 after each arithmetic operation.
1344 Exception flags are NOT fully supported.
1346 Signaling NaN's are NOT supported; they are treated the same
1349 Define INFINITY for support of infinity; otherwise a
1350 saturation arithmetic is implemented.
1352 Define NANS for support of Not-a-Number items; otherwise the
1353 arithmetic will never produce a NaN output, and might be confused
1355 If NaN's are supported, the output of `ecmp (a,b)' is -2 if
1356 either a or b is a NaN. This means asking `if (ecmp (a,b) < 0)'
1357 may not be legitimate. Use `if (ecmp (a,b) == -1)' for `less than'
1360 Denormals are always supported here where appropriate (e.g., not
1361 for conversion to DEC numbers). */
1363 /* Definitions for error codes that are passed to the common error handling
1366 For Digital Equipment PDP-11 and VAX computers, certain
1367 IBM systems, and others that use numbers with a 56-bit
1368 significand, the symbol DEC should be defined. In this
1369 mode, most floating point constants are given as arrays
1370 of octal integers to eliminate decimal to binary conversion
1371 errors that might be introduced by the compiler.
1373 For computers, such as IBM PC, that follow the IEEE
1374 Standard for Binary Floating Point Arithmetic (ANSI/IEEE
1375 Std 754-1985), the symbol IEEE should be defined.
1376 These numbers have 53-bit significands. In this mode, constants
1377 are provided as arrays of hexadecimal 16 bit integers.
1378 The endian-ness of generated values is controlled by
1379 REAL_WORDS_BIG_ENDIAN.
1381 To accommodate other types of computer arithmetic, all
1382 constants are also provided in a normal decimal radix
1383 which one can hope are correctly converted to a suitable
1384 format by the available C language compiler. To invoke
1385 this mode, the symbol UNK is defined.
1387 An important difference among these modes is a predefined
1388 set of machine arithmetic constants for each. The numbers
1389 MACHEP (the machine roundoff error), MAXNUM (largest number
1390 represented), and several other parameters are preset by
1391 the configuration symbol. Check the file const.c to
1392 ensure that these values are correct for your computer.
1394 For ANSI C compatibility, define ANSIC equal to 1. Currently
1395 this affects only the atan2 function and others that use it. */
1397 /* Constant definitions for math error conditions. */
1399 #define DOMAIN 1 /* argument domain error */
1400 #define SING 2 /* argument singularity */
1401 #define OVERFLOW 3 /* overflow range error */
1402 #define UNDERFLOW 4 /* underflow range error */
1403 #define TLOSS 5 /* total loss of precision */
1404 #define PLOSS 6 /* partial loss of precision */
1405 #define INVALID 7 /* NaN-producing operation */
1407 /* e type constants used by high precision check routines */
1409 #if LONG_DOUBLE_TYPE_SIZE == 128
1411 unsigned EMUSHORT ezero
[NE
] =
1412 {0x0000, 0x0000, 0x0000, 0x0000,
1413 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,};
1414 extern unsigned EMUSHORT ezero
[];
1417 unsigned EMUSHORT ehalf
[NE
] =
1418 {0x0000, 0x0000, 0x0000, 0x0000,
1419 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x3ffe,};
1420 extern unsigned EMUSHORT ehalf
[];
1423 unsigned EMUSHORT eone
[NE
] =
1424 {0x0000, 0x0000, 0x0000, 0x0000,
1425 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x3fff,};
1426 extern unsigned EMUSHORT eone
[];
1429 unsigned EMUSHORT etwo
[NE
] =
1430 {0x0000, 0x0000, 0x0000, 0x0000,
1431 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x4000,};
1432 extern unsigned EMUSHORT etwo
[];
1435 unsigned EMUSHORT e32
[NE
] =
1436 {0x0000, 0x0000, 0x0000, 0x0000,
1437 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x4004,};
1438 extern unsigned EMUSHORT e32
[];
1440 /* 6.93147180559945309417232121458176568075500134360255E-1 */
1441 unsigned EMUSHORT elog2
[NE
] =
1442 {0x40f3, 0xf6af, 0x03f2, 0xb398,
1443 0xc9e3, 0x79ab, 0150717, 0013767, 0130562, 0x3ffe,};
1444 extern unsigned EMUSHORT elog2
[];
1446 /* 1.41421356237309504880168872420969807856967187537695E0 */
1447 unsigned EMUSHORT esqrt2
[NE
] =
1448 {0x1d6f, 0xbe9f, 0x754a, 0x89b3,
1449 0x597d, 0x6484, 0174736, 0171463, 0132404, 0x3fff,};
1450 extern unsigned EMUSHORT esqrt2
[];
1452 /* 3.14159265358979323846264338327950288419716939937511E0 */
1453 unsigned EMUSHORT epi
[NE
] =
1454 {0x2902, 0x1cd1, 0x80dc, 0x628b,
1455 0xc4c6, 0xc234, 0020550, 0155242, 0144417, 0040000,};
1456 extern unsigned EMUSHORT epi
[];
1459 /* LONG_DOUBLE_TYPE_SIZE is other than 128 */
1460 unsigned EMUSHORT ezero
[NE
] =
1461 {0, 0000000, 0000000, 0000000, 0000000, 0000000,};
1462 unsigned EMUSHORT ehalf
[NE
] =
1463 {0, 0000000, 0000000, 0000000, 0100000, 0x3ffe,};
1464 unsigned EMUSHORT eone
[NE
] =
1465 {0, 0000000, 0000000, 0000000, 0100000, 0x3fff,};
1466 unsigned EMUSHORT etwo
[NE
] =
1467 {0, 0000000, 0000000, 0000000, 0100000, 0040000,};
1468 unsigned EMUSHORT e32
[NE
] =
1469 {0, 0000000, 0000000, 0000000, 0100000, 0040004,};
1470 unsigned EMUSHORT elog2
[NE
] =
1471 {0xc9e4, 0x79ab, 0150717, 0013767, 0130562, 0x3ffe,};
1472 unsigned EMUSHORT esqrt2
[NE
] =
1473 {0x597e, 0x6484, 0174736, 0171463, 0132404, 0x3fff,};
1474 unsigned EMUSHORT epi
[NE
] =
1475 {0xc4c6, 0xc234, 0020550, 0155242, 0144417, 0040000,};
1478 /* Control register for rounding precision.
1479 This can be set to 113 (if NE=10), 80 (if NE=6), 64, 56, 53, or 24 bits. */
1484 /* Clear out entire e-type number X. */
1488 register unsigned EMUSHORT
*x
;
1492 for (i
= 0; i
< NE
; i
++)
1496 /* Move e-type number from A to B. */
1500 register unsigned EMUSHORT
*a
, *b
;
1504 for (i
= 0; i
< NE
; i
++)
1509 /* Absolute value of e-type X. */
1513 unsigned EMUSHORT x
[];
1515 /* sign is top bit of last word of external format */
1516 x
[NE
- 1] &= 0x7fff;
1519 /* Negate the e-type number X. */
1523 unsigned EMUSHORT x
[];
1526 x
[NE
- 1] ^= 0x8000; /* Toggle the sign bit */
1529 /* Return 1 if sign bit of e-type number X is nonzero, else zero. */
1533 unsigned EMUSHORT x
[];
1536 if (x
[NE
- 1] & 0x8000)
1542 /* Return 1 if e-type number X is infinity, else return zero. */
1546 unsigned EMUSHORT x
[];
1553 if ((x
[NE
- 1] & 0x7fff) == 0x7fff)
1559 /* Check if e-type number is not a number. The bit pattern is one that we
1560 defined, so we know for sure how to detect it. */
1564 unsigned EMUSHORT x
[];
1569 /* NaN has maximum exponent */
1570 if ((x
[NE
- 1] & 0x7fff) != 0x7fff)
1572 /* ... and non-zero significand field. */
1573 for (i
= 0; i
< NE
- 1; i
++)
1583 /* Fill e-type number X with infinity pattern (IEEE)
1584 or largest possible number (non-IEEE). */
1588 register unsigned EMUSHORT
*x
;
1593 for (i
= 0; i
< NE
- 1; i
++)
1597 for (i
= 0; i
< NE
- 1; i
++)
1625 /* Output an e-type NaN.
1626 This generates Intel's quiet NaN pattern for extended real.
1627 The exponent is 7fff, the leading mantissa word is c000. */
1631 register unsigned EMUSHORT
*x
;
1636 for (i
= 0; i
< NE
- 2; i
++)
1639 *x
= (sign
<< 15) | 0x7fff;
1642 /* Move in an e-type number A, converting it to exploded e-type B. */
1646 unsigned EMUSHORT
*a
, *b
;
1648 register unsigned EMUSHORT
*p
, *q
;
1652 p
= a
+ (NE
- 1); /* point to last word of external number */
1653 /* get the sign bit */
1658 /* get the exponent */
1660 *q
++ &= 0x7fff; /* delete the sign bit */
1662 if ((*(q
- 1) & 0x7fff) == 0x7fff)
1668 for (i
= 3; i
< NI
; i
++)
1674 for (i
= 2; i
< NI
; i
++)
1680 /* clear high guard word */
1682 /* move in the significand */
1683 for (i
= 0; i
< NE
- 1; i
++)
1685 /* clear low guard word */
1689 /* Move out exploded e-type number A, converting it to e type B. */
1693 unsigned EMUSHORT
*a
, *b
;
1695 register unsigned EMUSHORT
*p
, *q
;
1696 unsigned EMUSHORT i
;
1700 q
= b
+ (NE
- 1); /* point to output exponent */
1701 /* combine sign and exponent */
1704 *q
-- = *p
++ | 0x8000;
1708 if (*(p
- 1) == 0x7fff)
1713 enan (b
, eiisneg (a
));
1721 /* skip over guard word */
1723 /* move the significand */
1724 for (j
= 0; j
< NE
- 1; j
++)
1728 /* Clear out exploded e-type number XI. */
1732 register unsigned EMUSHORT
*xi
;
1736 for (i
= 0; i
< NI
; i
++)
1740 /* Clear out exploded e-type XI, but don't touch the sign. */
1744 register unsigned EMUSHORT
*xi
;
1749 for (i
= 0; i
< NI
- 1; i
++)
1753 /* Move exploded e-type number from A to B. */
1757 register unsigned EMUSHORT
*a
, *b
;
1761 for (i
= 0; i
< NI
- 1; i
++)
1763 /* clear low guard word */
1767 /* Generate exploded e-type NaN.
1768 The explicit pattern for this is maximum exponent and
1769 top two significant bits set. */
1773 unsigned EMUSHORT x
[];
1781 /* Return nonzero if exploded e-type X is a NaN. */
1785 unsigned EMUSHORT x
[];
1789 if ((x
[E
] & 0x7fff) == 0x7fff)
1791 for (i
= M
+ 1; i
< NI
; i
++)
1800 /* Return nonzero if sign of exploded e-type X is nonzero. */
1804 unsigned EMUSHORT x
[];
1810 /* Fill exploded e-type X with infinity pattern.
1811 This has maximum exponent and significand all zeros. */
1815 unsigned EMUSHORT x
[];
1822 /* Return nonzero if exploded e-type X is infinite. */
1826 unsigned EMUSHORT x
[];
1833 if ((x
[E
] & 0x7fff) == 0x7fff)
1839 /* Compare significands of numbers in internal exploded e-type format.
1840 Guard words are included in the comparison.
1848 register unsigned EMUSHORT
*a
, *b
;
1852 a
+= M
; /* skip up to significand area */
1854 for (i
= M
; i
< NI
; i
++)
1862 if (*(--a
) > *(--b
))
1868 /* Shift significand of exploded e-type X down by 1 bit. */
1872 register unsigned EMUSHORT
*x
;
1874 register unsigned EMUSHORT bits
;
1877 x
+= M
; /* point to significand area */
1880 for (i
= M
; i
< NI
; i
++)
1892 /* Shift significand of exploded e-type X up by 1 bit. */
1896 register unsigned EMUSHORT
*x
;
1898 register unsigned EMUSHORT bits
;
1904 for (i
= M
; i
< NI
; i
++)
1917 /* Shift significand of exploded e-type X down by 8 bits. */
1921 register unsigned EMUSHORT
*x
;
1923 register unsigned EMUSHORT newbyt
, oldbyt
;
1928 for (i
= M
; i
< NI
; i
++)
1938 /* Shift significand of exploded e-type X up by 8 bits. */
1942 register unsigned EMUSHORT
*x
;
1945 register unsigned EMUSHORT newbyt
, oldbyt
;
1950 for (i
= M
; i
< NI
; i
++)
1960 /* Shift significand of exploded e-type X up by 16 bits. */
1964 register unsigned EMUSHORT
*x
;
1967 register unsigned EMUSHORT
*p
;
1972 for (i
= M
; i
< NI
- 1; i
++)
1978 /* Shift significand of exploded e-type X down by 16 bits. */
1982 register unsigned EMUSHORT
*x
;
1985 register unsigned EMUSHORT
*p
;
1990 for (i
= M
; i
< NI
- 1; i
++)
1996 /* Add significands of exploded e-type X and Y. X + Y replaces Y. */
2000 unsigned EMUSHORT
*x
, *y
;
2002 register unsigned EMULONG a
;
2009 for (i
= M
; i
< NI
; i
++)
2011 a
= (unsigned EMULONG
) (*x
) + (unsigned EMULONG
) (*y
) + carry
;
2016 *y
= (unsigned EMUSHORT
) a
;
2022 /* Subtract significands of exploded e-type X and Y. Y - X replaces Y. */
2026 unsigned EMUSHORT
*x
, *y
;
2035 for (i
= M
; i
< NI
; i
++)
2037 a
= (unsigned EMULONG
) (*y
) - (unsigned EMULONG
) (*x
) - carry
;
2042 *y
= (unsigned EMUSHORT
) a
;
2049 static unsigned EMUSHORT equot
[NI
];
2053 /* Radix 2 shift-and-add versions of multiply and divide */
2056 /* Divide significands */
2060 unsigned EMUSHORT den
[], num
[];
2063 register unsigned EMUSHORT
*p
, *q
;
2064 unsigned EMUSHORT j
;
2070 for (i
= M
; i
< NI
; i
++)
2075 /* Use faster compare and subtraction if denominator has only 15 bits of
2081 for (i
= M
+ 3; i
< NI
; i
++)
2086 if ((den
[M
+ 1] & 1) != 0)
2094 for (i
= 0; i
< NBITS
+ 2; i
++)
2112 /* The number of quotient bits to calculate is NBITS + 1 scaling guard
2113 bit + 1 roundoff bit. */
2118 for (i
= 0; i
< NBITS
+ 2; i
++)
2120 if (ecmpm (den
, num
) <= 0)
2123 j
= 1; /* quotient bit = 1 */
2137 /* test for nonzero remainder after roundoff bit */
2140 for (i
= M
; i
< NI
; i
++)
2148 for (i
= 0; i
< NI
; i
++)
2154 /* Multiply significands */
2158 unsigned EMUSHORT a
[], b
[];
2160 unsigned EMUSHORT
*p
, *q
;
2165 for (i
= M
; i
< NI
; i
++)
2170 while (*p
== 0) /* significand is not supposed to be zero */
2175 if ((*p
& 0xff) == 0)
2183 for (i
= 0; i
< k
; i
++)
2187 /* remember if there were any nonzero bits shifted out */
2194 for (i
= 0; i
< NI
; i
++)
2197 /* return flag for lost nonzero bits */
2203 /* Radix 65536 versions of multiply and divide. */
2205 /* Multiply significand of e-type number B
2206 by 16-bit quantity A, return e-type result to C. */
2211 unsigned EMUSHORT b
[], c
[];
2213 register unsigned EMUSHORT
*pp
;
2214 register unsigned EMULONG carry
;
2215 unsigned EMUSHORT
*ps
;
2216 unsigned EMUSHORT p
[NI
];
2217 unsigned EMULONG aa
, m
;
2226 for (i
=M
+1; i
<NI
; i
++)
2236 m
= (unsigned EMULONG
) aa
* *ps
--;
2237 carry
= (m
& 0xffff) + *pp
;
2238 *pp
-- = (unsigned EMUSHORT
)carry
;
2239 carry
= (carry
>> 16) + (m
>> 16) + *pp
;
2240 *pp
= (unsigned EMUSHORT
)carry
;
2241 *(pp
-1) = carry
>> 16;
2244 for (i
=M
; i
<NI
; i
++)
2248 /* Divide significands of exploded e-types NUM / DEN. Neither the
2249 numerator NUM nor the denominator DEN is permitted to have its high guard
2254 unsigned EMUSHORT den
[], num
[];
2257 register unsigned EMUSHORT
*p
;
2258 unsigned EMULONG tnum
;
2259 unsigned EMUSHORT j
, tdenm
, tquot
;
2260 unsigned EMUSHORT tprod
[NI
+1];
2266 for (i
=M
; i
<NI
; i
++)
2272 for (i
=M
; i
<NI
; i
++)
2274 /* Find trial quotient digit (the radix is 65536). */
2275 tnum
= (((unsigned EMULONG
) num
[M
]) << 16) + num
[M
+1];
2277 /* Do not execute the divide instruction if it will overflow. */
2278 if ((tdenm
* 0xffffL
) < tnum
)
2281 tquot
= tnum
/ tdenm
;
2282 /* Multiply denominator by trial quotient digit. */
2283 m16m ((unsigned int)tquot
, den
, tprod
);
2284 /* The quotient digit may have been overestimated. */
2285 if (ecmpm (tprod
, num
) > 0)
2289 if (ecmpm (tprod
, num
) > 0)
2299 /* test for nonzero remainder after roundoff bit */
2302 for (i
=M
; i
<NI
; i
++)
2309 for (i
=0; i
<NI
; i
++)
2315 /* Multiply significands of exploded e-type A and B, result in B. */
2319 unsigned EMUSHORT a
[], b
[];
2321 unsigned EMUSHORT
*p
, *q
;
2322 unsigned EMUSHORT pprod
[NI
];
2323 unsigned EMUSHORT j
;
2328 for (i
=M
; i
<NI
; i
++)
2334 for (i
=M
+1; i
<NI
; i
++)
2342 m16m ((unsigned int) *p
--, b
, pprod
);
2343 eaddm(pprod
, equot
);
2349 for (i
=0; i
<NI
; i
++)
2352 /* return flag for lost nonzero bits */
2358 /* Normalize and round off.
2360 The internal format number to be rounded is S.
2361 Input LOST is 0 if the value is exact. This is the so-called sticky bit.
2363 Input SUBFLG indicates whether the number was obtained
2364 by a subtraction operation. In that case if LOST is nonzero
2365 then the number is slightly smaller than indicated.
2367 Input EXP is the biased exponent, which may be negative.
2368 the exponent field of S is ignored but is replaced by
2369 EXP as adjusted by normalization and rounding.
2371 Input RCNTRL is the rounding control. If it is nonzero, the
2372 returned value will be rounded to RNDPRC bits.
2374 For future reference: In order for emdnorm to round off denormal
2375 significands at the right point, the input exponent must be
2376 adjusted to be the actual value it would have after conversion to
2377 the final floating point type. This adjustment has been
2378 implemented for all type conversions (etoe53, etc.) and decimal
2379 conversions, but not for the arithmetic functions (eadd, etc.).
2380 Data types having standard 15-bit exponents are not affected by
2381 this, but SFmode and DFmode are affected. For example, ediv with
2382 rndprc = 24 will not round correctly to 24-bit precision if the
2383 result is denormal. */
2385 static int rlast
= -1;
2387 static unsigned EMUSHORT rmsk
= 0;
2388 static unsigned EMUSHORT rmbit
= 0;
2389 static unsigned EMUSHORT rebit
= 0;
2391 static unsigned EMUSHORT rbit
[NI
];
2394 emdnorm (s
, lost
, subflg
, exp
, rcntrl
)
2395 unsigned EMUSHORT s
[];
2402 unsigned EMUSHORT r
;
2407 /* a blank significand could mean either zero or infinity. */
2420 if ((j
> NBITS
) && (exp
< 32767))
2428 if (exp
> (EMULONG
) (-NBITS
- 1))
2441 /* Round off, unless told not to by rcntrl. */
2444 /* Set up rounding parameters if the control register changed. */
2445 if (rndprc
!= rlast
)
2452 rw
= NI
- 1; /* low guard word */
2472 /* For DEC or IBM arithmetic */
2499 /* Shift down 1 temporarily if the data structure has an implied
2500 most significant bit and the number is denormal.
2501 Intel long double denormals also lose one bit of precision. */
2502 if ((exp
<= 0) && (rndprc
!= NBITS
)
2503 && ((rndprc
!= 64) || ((rndprc
== 64) && ! REAL_WORDS_BIG_ENDIAN
)))
2505 lost
|= s
[NI
- 1] & 1;
2508 /* Clear out all bits below the rounding bit,
2509 remembering in r if any were nonzero. */
2523 if ((r
& rmbit
) != 0)
2528 { /* round to even */
2529 if ((s
[re
] & rebit
) == 0)
2541 /* Undo the temporary shift for denormal values. */
2542 if ((exp
<= 0) && (rndprc
!= NBITS
)
2543 && ((rndprc
!= 64) || ((rndprc
== 64) && ! REAL_WORDS_BIG_ENDIAN
)))
2548 { /* overflow on roundoff */
2561 for (i
= 2; i
< NI
- 1; i
++)
2564 warning ("floating point overflow");
2568 for (i
= M
+ 1; i
< NI
- 1; i
++)
2571 if ((rndprc
< 64) || (rndprc
== 113))
2586 s
[1] = (unsigned EMUSHORT
) exp
;
2589 /* Subtract. C = B - A, all e type numbers. */
2591 static int subflg
= 0;
2595 unsigned EMUSHORT
*a
, *b
, *c
;
2609 /* Infinity minus infinity is a NaN.
2610 Test for subtracting infinities of the same sign. */
2611 if (eisinf (a
) && eisinf (b
)
2612 && ((eisneg (a
) ^ eisneg (b
)) == 0))
2614 mtherr ("esub", INVALID
);
2623 /* Add. C = A + B, all e type. */
2627 unsigned EMUSHORT
*a
, *b
, *c
;
2631 /* NaN plus anything is a NaN. */
2642 /* Infinity minus infinity is a NaN.
2643 Test for adding infinities of opposite signs. */
2644 if (eisinf (a
) && eisinf (b
)
2645 && ((eisneg (a
) ^ eisneg (b
)) != 0))
2647 mtherr ("esub", INVALID
);
2656 /* Arithmetic common to both addition and subtraction. */
2660 unsigned EMUSHORT
*a
, *b
, *c
;
2662 unsigned EMUSHORT ai
[NI
], bi
[NI
], ci
[NI
];
2664 EMULONG lt
, lta
, ltb
;
2685 /* compare exponents */
2690 { /* put the larger number in bi */
2700 if (lt
< (EMULONG
) (-NBITS
- 1))
2701 goto done
; /* answer same as larger addend */
2703 lost
= eshift (ai
, k
); /* shift the smaller number down */
2707 /* exponents were the same, so must compare significands */
2710 { /* the numbers are identical in magnitude */
2711 /* if different signs, result is zero */
2717 /* if same sign, result is double */
2718 /* double denormalized tiny number */
2719 if ((bi
[E
] == 0) && ((bi
[3] & 0x8000) == 0))
2724 /* add 1 to exponent unless both are zero! */
2725 for (j
= 1; j
< NI
- 1; j
++)
2741 bi
[E
] = (unsigned EMUSHORT
) ltb
;
2745 { /* put the larger number in bi */
2761 emdnorm (bi
, lost
, subflg
, ltb
, 64);
2767 /* Divide: C = B/A, all e type. */
2771 unsigned EMUSHORT
*a
, *b
, *c
;
2773 unsigned EMUSHORT ai
[NI
], bi
[NI
];
2775 EMULONG lt
, lta
, ltb
;
2777 /* IEEE says if result is not a NaN, the sign is "-" if and only if
2778 operands have opposite signs -- but flush -0 to 0 later if not IEEE. */
2779 sign
= eisneg(a
) ^ eisneg(b
);
2782 /* Return any NaN input. */
2793 /* Zero over zero, or infinity over infinity, is a NaN. */
2794 if (((ecmp (a
, ezero
) == 0) && (ecmp (b
, ezero
) == 0))
2795 || (eisinf (a
) && eisinf (b
)))
2797 mtherr ("ediv", INVALID
);
2802 /* Infinity over anything else is infinity. */
2809 /* Anything else over infinity is zero. */
2821 { /* See if numerator is zero. */
2822 for (i
= 1; i
< NI
- 1; i
++)
2826 ltb
-= enormlz (bi
);
2836 { /* possible divide by zero */
2837 for (i
= 1; i
< NI
- 1; i
++)
2841 lta
-= enormlz (ai
);
2845 /* Divide by zero is not an invalid operation.
2846 It is a divide-by-zero operation! */
2848 mtherr ("ediv", SING
);
2854 /* calculate exponent */
2855 lt
= ltb
- lta
+ EXONE
;
2856 emdnorm (bi
, i
, 0, lt
, 64);
2863 && (ecmp (c
, ezero
) != 0)
2866 *(c
+(NE
-1)) |= 0x8000;
2868 *(c
+(NE
-1)) &= ~0x8000;
2871 /* Multiply e-types A and B, return e-type product C. */
2875 unsigned EMUSHORT
*a
, *b
, *c
;
2877 unsigned EMUSHORT ai
[NI
], bi
[NI
];
2879 EMULONG lt
, lta
, ltb
;
2881 /* IEEE says if result is not a NaN, the sign is "-" if and only if
2882 operands have opposite signs -- but flush -0 to 0 later if not IEEE. */
2883 sign
= eisneg(a
) ^ eisneg(b
);
2886 /* NaN times anything is the same NaN. */
2897 /* Zero times infinity is a NaN. */
2898 if ((eisinf (a
) && (ecmp (b
, ezero
) == 0))
2899 || (eisinf (b
) && (ecmp (a
, ezero
) == 0)))
2901 mtherr ("emul", INVALID
);
2906 /* Infinity times anything else is infinity. */
2908 if (eisinf (a
) || eisinf (b
))
2920 for (i
= 1; i
< NI
- 1; i
++)
2924 lta
-= enormlz (ai
);
2935 for (i
= 1; i
< NI
- 1; i
++)
2939 ltb
-= enormlz (bi
);
2948 /* Multiply significands */
2950 /* calculate exponent */
2951 lt
= lta
+ ltb
- (EXONE
- 1);
2952 emdnorm (bi
, j
, 0, lt
, 64);
2959 && (ecmp (c
, ezero
) != 0)
2962 *(c
+(NE
-1)) |= 0x8000;
2964 *(c
+(NE
-1)) &= ~0x8000;
2967 /* Convert double precision PE to e-type Y. */
2971 unsigned EMUSHORT
*pe
, *y
;
2980 ibmtoe (pe
, y
, DFmode
);
2983 register unsigned EMUSHORT r
;
2984 register unsigned EMUSHORT
*e
, *p
;
2985 unsigned EMUSHORT yy
[NI
];
2989 denorm
= 0; /* flag if denormalized number */
2991 if (! REAL_WORDS_BIG_ENDIAN
)
2997 yy
[M
] = (r
& 0x0f) | 0x10;
2998 r
&= ~0x800f; /* strip sign and 4 significand bits */
3003 if (! REAL_WORDS_BIG_ENDIAN
)
3005 if (((pe
[3] & 0xf) != 0) || (pe
[2] != 0)
3006 || (pe
[1] != 0) || (pe
[0] != 0))
3008 enan (y
, yy
[0] != 0);
3014 if (((pe
[0] & 0xf) != 0) || (pe
[1] != 0)
3015 || (pe
[2] != 0) || (pe
[3] != 0))
3017 enan (y
, yy
[0] != 0);
3028 #endif /* INFINITY */
3030 /* If zero exponent, then the significand is denormalized.
3031 So take back the understood high significand bit. */
3042 if (! REAL_WORDS_BIG_ENDIAN
)
3058 { /* if zero exponent, then normalize the significand */
3059 if ((k
= enormlz (yy
)) > NBITS
)
3062 yy
[E
] -= (unsigned EMUSHORT
) (k
- 1);
3065 #endif /* not IBM */
3066 #endif /* not DEC */
3069 /* Convert double extended precision float PE to e type Y. */
3073 unsigned EMUSHORT
*pe
, *y
;
3075 unsigned EMUSHORT yy
[NI
];
3076 unsigned EMUSHORT
*e
, *p
, *q
;
3081 for (i
= 0; i
< NE
- 5; i
++)
3083 /* This precision is not ordinarily supported on DEC or IBM. */
3085 for (i
= 0; i
< 5; i
++)
3089 p
= &yy
[0] + (NE
- 1);
3092 for (i
= 0; i
< 5; i
++)
3096 if (! REAL_WORDS_BIG_ENDIAN
)
3098 for (i
= 0; i
< 5; i
++)
3101 /* For denormal long double Intel format, shift significand up one
3102 -- but only if the top significand bit is zero. A top bit of 1
3103 is "pseudodenormal" when the exponent is zero. */
3104 if((yy
[NE
-1] & 0x7fff) == 0 && (yy
[NE
-2] & 0x8000) == 0)
3106 unsigned EMUSHORT temp
[NI
];
3116 p
= &yy
[0] + (NE
- 1);
3117 #ifdef ARM_EXTENDED_IEEE_FORMAT
3118 /* For ARMs, the exponent is in the lowest 15 bits of the word. */
3119 *p
-- = (e
[0] & 0x8000) | (e
[1] & 0x7ffff);
3125 for (i
= 0; i
< 4; i
++)
3130 /* Point to the exponent field and check max exponent cases. */
3132 if ((*p
& 0x7fff) == 0x7fff)
3135 if (! REAL_WORDS_BIG_ENDIAN
)
3137 for (i
= 0; i
< 4; i
++)
3139 if ((i
!= 3 && pe
[i
] != 0)
3140 /* Anything but 0x8000 here, including 0, is a NaN. */
3141 || (i
== 3 && pe
[i
] != 0x8000))
3143 enan (y
, (*p
& 0x8000) != 0);
3150 #ifdef ARM_EXTENDED_IEEE_FORMAT
3151 for (i
= 2; i
<= 5; i
++)
3155 enan (y
, (*p
& 0x8000) != 0);
3160 /* In Motorola extended precision format, the most significant
3161 bit of an infinity mantissa could be either 1 or 0. It is
3162 the lower order bits that tell whether the value is a NaN. */
3163 if ((pe
[2] & 0x7fff) != 0)
3166 for (i
= 3; i
<= 5; i
++)
3171 enan (y
, (*p
& 0x8000) != 0);
3175 #endif /* not ARM */
3184 #endif /* INFINITY */
3187 for (i
= 0; i
< NE
; i
++)
3191 /* Convert 128-bit long double precision float PE to e type Y. */
3195 unsigned EMUSHORT
*pe
, *y
;
3197 register unsigned EMUSHORT r
;
3198 unsigned EMUSHORT
*e
, *p
;
3199 unsigned EMUSHORT yy
[NI
];
3206 if (! REAL_WORDS_BIG_ENDIAN
)
3218 if (! REAL_WORDS_BIG_ENDIAN
)
3220 for (i
= 0; i
< 7; i
++)
3224 enan (y
, yy
[0] != 0);
3231 for (i
= 1; i
< 8; i
++)
3235 enan (y
, yy
[0] != 0);
3247 #endif /* INFINITY */
3251 if (! REAL_WORDS_BIG_ENDIAN
)
3253 for (i
= 0; i
< 7; i
++)
3259 for (i
= 0; i
< 7; i
++)
3263 /* If denormal, remove the implied bit; else shift down 1. */
3276 /* Convert single precision float PE to e type Y. */
3280 unsigned EMUSHORT
*pe
, *y
;
3284 ibmtoe (pe
, y
, SFmode
);
3287 register unsigned EMUSHORT r
;
3288 register unsigned EMUSHORT
*e
, *p
;
3289 unsigned EMUSHORT yy
[NI
];
3293 denorm
= 0; /* flag if denormalized number */
3296 if (! REAL_WORDS_BIG_ENDIAN
)
3306 yy
[M
] = (r
& 0x7f) | 0200;
3307 r
&= ~0x807f; /* strip sign and 7 significand bits */
3312 if (REAL_WORDS_BIG_ENDIAN
)
3314 if (((pe
[0] & 0x7f) != 0) || (pe
[1] != 0))
3316 enan (y
, yy
[0] != 0);
3322 if (((pe
[1] & 0x7f) != 0) || (pe
[0] != 0))
3324 enan (y
, yy
[0] != 0);
3335 #endif /* INFINITY */
3337 /* If zero exponent, then the significand is denormalized.
3338 So take back the understood high significand bit. */
3351 if (! REAL_WORDS_BIG_ENDIAN
)
3361 { /* if zero exponent, then normalize the significand */
3362 if ((k
= enormlz (yy
)) > NBITS
)
3365 yy
[E
] -= (unsigned EMUSHORT
) (k
- 1);
3368 #endif /* not IBM */
3371 /* Convert e-type X to IEEE 128-bit long double format E. */
3375 unsigned EMUSHORT
*x
, *e
;
3377 unsigned EMUSHORT xi
[NI
];
3384 make_nan (e
, eisneg (x
), TFmode
);
3389 exp
= (EMULONG
) xi
[E
];
3394 /* round off to nearest or even */
3397 emdnorm (xi
, 0, 0, exp
, 64);
3403 /* Convert exploded e-type X, that has already been rounded to
3404 113-bit precision, to IEEE 128-bit long double format Y. */
3408 unsigned EMUSHORT
*a
, *b
;
3410 register unsigned EMUSHORT
*p
, *q
;
3411 unsigned EMUSHORT i
;
3416 make_nan (b
, eiisneg (a
), TFmode
);
3421 if (REAL_WORDS_BIG_ENDIAN
)
3424 q
= b
+ 7; /* point to output exponent */
3426 /* If not denormal, delete the implied bit. */
3431 /* combine sign and exponent */
3433 if (REAL_WORDS_BIG_ENDIAN
)
3436 *q
++ = *p
++ | 0x8000;
3443 *q
-- = *p
++ | 0x8000;
3447 /* skip over guard word */
3449 /* move the significand */
3450 if (REAL_WORDS_BIG_ENDIAN
)
3452 for (i
= 0; i
< 7; i
++)
3457 for (i
= 0; i
< 7; i
++)
3462 /* Convert e-type X to IEEE double extended format E. */
3466 unsigned EMUSHORT
*x
, *e
;
3468 unsigned EMUSHORT xi
[NI
];
3475 make_nan (e
, eisneg (x
), XFmode
);
3480 /* adjust exponent for offset */
3481 exp
= (EMULONG
) xi
[E
];
3486 /* round off to nearest or even */
3489 emdnorm (xi
, 0, 0, exp
, 64);
3495 /* Convert exploded e-type X, that has already been rounded to
3496 64-bit precision, to IEEE double extended format Y. */
3500 unsigned EMUSHORT
*a
, *b
;
3502 register unsigned EMUSHORT
*p
, *q
;
3503 unsigned EMUSHORT i
;
3508 make_nan (b
, eiisneg (a
), XFmode
);
3512 /* Shift denormal long double Intel format significand down one bit. */
3513 if ((a
[E
] == 0) && ! REAL_WORDS_BIG_ENDIAN
)
3523 if (REAL_WORDS_BIG_ENDIAN
)
3527 q
= b
+ 4; /* point to output exponent */
3528 #if LONG_DOUBLE_TYPE_SIZE == 96
3529 /* Clear the last two bytes of 12-byte Intel format */
3535 /* combine sign and exponent */
3539 *q
++ = *p
++ | 0x8000;
3546 *q
-- = *p
++ | 0x8000;
3551 if (REAL_WORDS_BIG_ENDIAN
)
3553 #ifdef ARM_EXTENDED_IEEE_FORMAT
3554 /* The exponent is in the lowest 15 bits of the first word. */
3555 *q
++ = i
? 0x8000 : 0;
3559 *q
++ = *p
++ | 0x8000;
3568 *q
-- = *p
++ | 0x8000;
3573 /* skip over guard word */
3575 /* move the significand */
3577 for (i
= 0; i
< 4; i
++)
3581 for (i
= 0; i
< 4; i
++)
3585 if (REAL_WORDS_BIG_ENDIAN
)
3587 for (i
= 0; i
< 4; i
++)
3595 /* Intel long double infinity significand. */
3603 for (i
= 0; i
< 4; i
++)
3609 /* e type to double precision. */
3612 /* Convert e-type X to DEC-format double E. */
3616 unsigned EMUSHORT
*x
, *e
;
3618 etodec (x
, e
); /* see etodec.c */
3621 /* Convert exploded e-type X, that has already been rounded to
3622 56-bit double precision, to DEC double Y. */
3626 unsigned EMUSHORT
*x
, *y
;
3633 /* Convert e-type X to IBM 370-format double E. */
3637 unsigned EMUSHORT
*x
, *e
;
3639 etoibm (x
, e
, DFmode
);
3642 /* Convert exploded e-type X, that has already been rounded to
3643 56-bit precision, to IBM 370 double Y. */
3647 unsigned EMUSHORT
*x
, *y
;
3649 toibm (x
, y
, DFmode
);
3652 #else /* it's neither DEC nor IBM */
3654 /* Convert e-type X to IEEE double E. */
3658 unsigned EMUSHORT
*x
, *e
;
3660 unsigned EMUSHORT xi
[NI
];
3667 make_nan (e
, eisneg (x
), DFmode
);
3672 /* adjust exponent for offsets */
3673 exp
= (EMULONG
) xi
[E
] - (EXONE
- 0x3ff);
3678 /* round off to nearest or even */
3681 emdnorm (xi
, 0, 0, exp
, 64);
3687 /* Convert exploded e-type X, that has already been rounded to
3688 53-bit precision, to IEEE double Y. */
3692 unsigned EMUSHORT
*x
, *y
;
3694 unsigned EMUSHORT i
;
3695 unsigned EMUSHORT
*p
;
3700 make_nan (y
, eiisneg (x
), DFmode
);
3706 if (! REAL_WORDS_BIG_ENDIAN
)
3709 *y
= 0; /* output high order */
3711 *y
= 0x8000; /* output sign bit */
3714 if (i
>= (unsigned int) 2047)
3716 /* Saturate at largest number less than infinity. */
3719 if (! REAL_WORDS_BIG_ENDIAN
)
3733 *y
|= (unsigned EMUSHORT
) 0x7fef;
3734 if (! REAL_WORDS_BIG_ENDIAN
)
3759 i
|= *p
++ & (unsigned EMUSHORT
) 0x0f; /* *p = xi[M] */
3760 *y
|= (unsigned EMUSHORT
) i
; /* high order output already has sign bit set */
3761 if (! REAL_WORDS_BIG_ENDIAN
)
3776 #endif /* not IBM */
3777 #endif /* not DEC */
3781 /* e type to single precision. */
3784 /* Convert e-type X to IBM 370 float E. */
3788 unsigned EMUSHORT
*x
, *e
;
3790 etoibm (x
, e
, SFmode
);
3793 /* Convert exploded e-type X, that has already been rounded to
3794 float precision, to IBM 370 float Y. */
3798 unsigned EMUSHORT
*x
, *y
;
3800 toibm (x
, y
, SFmode
);
3804 /* Convert e-type X to IEEE float E. DEC float is the same as IEEE float. */
3808 unsigned EMUSHORT
*x
, *e
;
3811 unsigned EMUSHORT xi
[NI
];
3817 make_nan (e
, eisneg (x
), SFmode
);
3822 /* adjust exponent for offsets */
3823 exp
= (EMULONG
) xi
[E
] - (EXONE
- 0177);
3828 /* round off to nearest or even */
3831 emdnorm (xi
, 0, 0, exp
, 64);
3837 /* Convert exploded e-type X, that has already been rounded to
3838 float precision, to IEEE float Y. */
3842 unsigned EMUSHORT
*x
, *y
;
3844 unsigned EMUSHORT i
;
3845 unsigned EMUSHORT
*p
;
3850 make_nan (y
, eiisneg (x
), SFmode
);
3856 if (! REAL_WORDS_BIG_ENDIAN
)
3862 *y
= 0; /* output high order */
3864 *y
= 0x8000; /* output sign bit */
3867 /* Handle overflow cases. */
3871 *y
|= (unsigned EMUSHORT
) 0x7f80;
3876 if (! REAL_WORDS_BIG_ENDIAN
)
3884 #else /* no INFINITY */
3885 *y
|= (unsigned EMUSHORT
) 0x7f7f;
3890 if (! REAL_WORDS_BIG_ENDIAN
)
3901 #endif /* no INFINITY */
3913 i
|= *p
++ & (unsigned EMUSHORT
) 0x7f; /* *p = xi[M] */
3914 /* High order output already has sign bit set. */
3920 if (! REAL_WORDS_BIG_ENDIAN
)
3929 #endif /* not IBM */
3931 /* Compare two e type numbers.
3935 -2 if either a or b is a NaN. */
3939 unsigned EMUSHORT
*a
, *b
;
3941 unsigned EMUSHORT ai
[NI
], bi
[NI
];
3942 register unsigned EMUSHORT
*p
, *q
;
3947 if (eisnan (a
) || eisnan (b
))
3956 { /* the signs are different */
3958 for (i
= 1; i
< NI
- 1; i
++)
3972 /* both are the same sign */
3987 return (0); /* equality */
3991 if (*(--p
) > *(--q
))
3992 return (msign
); /* p is bigger */
3994 return (-msign
); /* p is littler */
3997 /* Find e-type nearest integer to X, as floor (X + 0.5). */
4001 unsigned EMUSHORT
*x
, *y
;
4007 /* Convert HOST_WIDE_INT LP to e type Y. */
4012 unsigned EMUSHORT
*y
;
4014 unsigned EMUSHORT yi
[NI
];
4015 unsigned HOST_WIDE_INT ll
;
4021 /* make it positive */
4022 ll
= (unsigned HOST_WIDE_INT
) (-(*lp
));
4023 yi
[0] = 0xffff; /* put correct sign in the e type number */
4027 ll
= (unsigned HOST_WIDE_INT
) (*lp
);
4029 /* move the long integer to yi significand area */
4030 #if HOST_BITS_PER_WIDE_INT == 64
4031 yi
[M
] = (unsigned EMUSHORT
) (ll
>> 48);
4032 yi
[M
+ 1] = (unsigned EMUSHORT
) (ll
>> 32);
4033 yi
[M
+ 2] = (unsigned EMUSHORT
) (ll
>> 16);
4034 yi
[M
+ 3] = (unsigned EMUSHORT
) ll
;
4035 yi
[E
] = EXONE
+ 47; /* exponent if normalize shift count were 0 */
4037 yi
[M
] = (unsigned EMUSHORT
) (ll
>> 16);
4038 yi
[M
+ 1] = (unsigned EMUSHORT
) ll
;
4039 yi
[E
] = EXONE
+ 15; /* exponent if normalize shift count were 0 */
4042 if ((k
= enormlz (yi
)) > NBITS
)/* normalize the significand */
4043 ecleaz (yi
); /* it was zero */
4045 yi
[E
] -= (unsigned EMUSHORT
) k
;/* subtract shift count from exponent */
4046 emovo (yi
, y
); /* output the answer */
4049 /* Convert unsigned HOST_WIDE_INT LP to e type Y. */
4053 unsigned HOST_WIDE_INT
*lp
;
4054 unsigned EMUSHORT
*y
;
4056 unsigned EMUSHORT yi
[NI
];
4057 unsigned HOST_WIDE_INT ll
;
4063 /* move the long integer to ayi significand area */
4064 #if HOST_BITS_PER_WIDE_INT == 64
4065 yi
[M
] = (unsigned EMUSHORT
) (ll
>> 48);
4066 yi
[M
+ 1] = (unsigned EMUSHORT
) (ll
>> 32);
4067 yi
[M
+ 2] = (unsigned EMUSHORT
) (ll
>> 16);
4068 yi
[M
+ 3] = (unsigned EMUSHORT
) ll
;
4069 yi
[E
] = EXONE
+ 47; /* exponent if normalize shift count were 0 */
4071 yi
[M
] = (unsigned EMUSHORT
) (ll
>> 16);
4072 yi
[M
+ 1] = (unsigned EMUSHORT
) ll
;
4073 yi
[E
] = EXONE
+ 15; /* exponent if normalize shift count were 0 */
4076 if ((k
= enormlz (yi
)) > NBITS
)/* normalize the significand */
4077 ecleaz (yi
); /* it was zero */
4079 yi
[E
] -= (unsigned EMUSHORT
) k
; /* subtract shift count from exponent */
4080 emovo (yi
, y
); /* output the answer */
4084 /* Find signed HOST_WIDE_INT integer I and floating point fractional
4085 part FRAC of e-type (packed internal format) floating point input X.
4086 The integer output I has the sign of the input, except that
4087 positive overflow is permitted if FIXUNS_TRUNC_LIKE_FIX_TRUNC.
4088 The output e-type fraction FRAC is the positive fractional
4093 unsigned EMUSHORT
*x
;
4095 unsigned EMUSHORT
*frac
;
4097 unsigned EMUSHORT xi
[NI
];
4099 unsigned HOST_WIDE_INT ll
;
4102 k
= (int) xi
[E
] - (EXONE
- 1);
4105 /* if exponent <= 0, integer = 0 and real output is fraction */
4110 if (k
> (HOST_BITS_PER_WIDE_INT
- 1))
4112 /* long integer overflow: output large integer
4113 and correct fraction */
4115 *i
= ((unsigned HOST_WIDE_INT
) 1) << (HOST_BITS_PER_WIDE_INT
- 1);
4118 #ifdef FIXUNS_TRUNC_LIKE_FIX_TRUNC
4119 /* In this case, let it overflow and convert as if unsigned. */
4120 euifrac (x
, &ll
, frac
);
4121 *i
= (HOST_WIDE_INT
) ll
;
4124 /* In other cases, return the largest positive integer. */
4125 *i
= (((unsigned HOST_WIDE_INT
) 1) << (HOST_BITS_PER_WIDE_INT
- 1)) - 1;
4130 warning ("overflow on truncation to integer");
4134 /* Shift more than 16 bits: first shift up k-16 mod 16,
4135 then shift up by 16's. */
4136 j
= k
- ((k
>> 4) << 4);
4143 ll
= (ll
<< 16) | xi
[M
];
4145 while ((k
-= 16) > 0);
4152 /* shift not more than 16 bits */
4154 *i
= (HOST_WIDE_INT
) xi
[M
] & 0xffff;
4161 if ((k
= enormlz (xi
)) > NBITS
)
4164 xi
[E
] -= (unsigned EMUSHORT
) k
;
4170 /* Find unsigned HOST_WIDE_INT integer I and floating point fractional part
4171 FRAC of e-type X. A negative input yields integer output = 0 but
4172 correct fraction. */
4175 euifrac (x
, i
, frac
)
4176 unsigned EMUSHORT
*x
;
4177 unsigned HOST_WIDE_INT
*i
;
4178 unsigned EMUSHORT
*frac
;
4180 unsigned HOST_WIDE_INT ll
;
4181 unsigned EMUSHORT xi
[NI
];
4185 k
= (int) xi
[E
] - (EXONE
- 1);
4188 /* if exponent <= 0, integer = 0 and argument is fraction */
4193 if (k
> HOST_BITS_PER_WIDE_INT
)
4195 /* Long integer overflow: output large integer
4196 and correct fraction.
4197 Note, the BSD microvax compiler says that ~(0UL)
4198 is a syntax error. */
4202 warning ("overflow on truncation to unsigned integer");
4206 /* Shift more than 16 bits: first shift up k-16 mod 16,
4207 then shift up by 16's. */
4208 j
= k
- ((k
>> 4) << 4);
4215 ll
= (ll
<< 16) | xi
[M
];
4217 while ((k
-= 16) > 0);
4222 /* shift not more than 16 bits */
4224 *i
= (HOST_WIDE_INT
) xi
[M
] & 0xffff;
4227 if (xi
[0]) /* A negative value yields unsigned integer 0. */
4233 if ((k
= enormlz (xi
)) > NBITS
)
4236 xi
[E
] -= (unsigned EMUSHORT
) k
;
4241 /* Shift the significand of exploded e-type X up or down by SC bits. */
4245 unsigned EMUSHORT
*x
;
4248 unsigned EMUSHORT lost
;
4249 unsigned EMUSHORT
*p
;
4262 lost
|= *p
; /* remember lost bits */
4303 return ((int) lost
);
4306 /* Shift normalize the significand area of exploded e-type X.
4307 Return the shift count (up = positive). */
4311 unsigned EMUSHORT x
[];
4313 register unsigned EMUSHORT
*p
;
4322 return (0); /* already normalized */
4328 /* With guard word, there are NBITS+16 bits available.
4329 Return true if all are zero. */
4333 /* see if high byte is zero */
4334 while ((*p
& 0xff00) == 0)
4339 /* now shift 1 bit at a time */
4340 while ((*p
& 0x8000) == 0)
4346 mtherr ("enormlz", UNDERFLOW
);
4352 /* Normalize by shifting down out of the high guard word
4353 of the significand */
4368 mtherr ("enormlz", OVERFLOW
);
4375 /* Powers of ten used in decimal <-> binary conversions. */
4380 #if LONG_DOUBLE_TYPE_SIZE == 128
4381 static unsigned EMUSHORT etens
[NTEN
+ 1][NE
] =
4383 {0x6576, 0x4a92, 0x804a, 0x153f,
4384 0xc94c, 0x979a, 0x8a20, 0x5202, 0xc460, 0x7525,}, /* 10**4096 */
4385 {0x6a32, 0xce52, 0x329a, 0x28ce,
4386 0xa74d, 0x5de4, 0xc53d, 0x3b5d, 0x9e8b, 0x5a92,}, /* 10**2048 */
4387 {0x526c, 0x50ce, 0xf18b, 0x3d28,
4388 0x650d, 0x0c17, 0x8175, 0x7586, 0xc976, 0x4d48,},
4389 {0x9c66, 0x58f8, 0xbc50, 0x5c54,
4390 0xcc65, 0x91c6, 0xa60e, 0xa0ae, 0xe319, 0x46a3,},
4391 {0x851e, 0xeab7, 0x98fe, 0x901b,
4392 0xddbb, 0xde8d, 0x9df9, 0xebfb, 0xaa7e, 0x4351,},
4393 {0x0235, 0x0137, 0x36b1, 0x336c,
4394 0xc66f, 0x8cdf, 0x80e9, 0x47c9, 0x93ba, 0x41a8,},
4395 {0x50f8, 0x25fb, 0xc76b, 0x6b71,
4396 0x3cbf, 0xa6d5, 0xffcf, 0x1f49, 0xc278, 0x40d3,},
4397 {0x0000, 0x0000, 0x0000, 0x0000,
4398 0xf020, 0xb59d, 0x2b70, 0xada8, 0x9dc5, 0x4069,},
4399 {0x0000, 0x0000, 0x0000, 0x0000,
4400 0x0000, 0x0000, 0x0400, 0xc9bf, 0x8e1b, 0x4034,},
4401 {0x0000, 0x0000, 0x0000, 0x0000,
4402 0x0000, 0x0000, 0x0000, 0x2000, 0xbebc, 0x4019,},
4403 {0x0000, 0x0000, 0x0000, 0x0000,
4404 0x0000, 0x0000, 0x0000, 0x0000, 0x9c40, 0x400c,},
4405 {0x0000, 0x0000, 0x0000, 0x0000,
4406 0x0000, 0x0000, 0x0000, 0x0000, 0xc800, 0x4005,},
4407 {0x0000, 0x0000, 0x0000, 0x0000,
4408 0x0000, 0x0000, 0x0000, 0x0000, 0xa000, 0x4002,}, /* 10**1 */
4411 static unsigned EMUSHORT emtens
[NTEN
+ 1][NE
] =
4413 {0x2030, 0xcffc, 0xa1c3, 0x8123,
4414 0x2de3, 0x9fde, 0xd2ce, 0x04c8, 0xa6dd, 0x0ad8,}, /* 10**-4096 */
4415 {0x8264, 0xd2cb, 0xf2ea, 0x12d4,
4416 0x4925, 0x2de4, 0x3436, 0x534f, 0xceae, 0x256b,}, /* 10**-2048 */
4417 {0xf53f, 0xf698, 0x6bd3, 0x0158,
4418 0x87a6, 0xc0bd, 0xda57, 0x82a5, 0xa2a6, 0x32b5,},
4419 {0xe731, 0x04d4, 0xe3f2, 0xd332,
4420 0x7132, 0xd21c, 0xdb23, 0xee32, 0x9049, 0x395a,},
4421 {0xa23e, 0x5308, 0xfefb, 0x1155,
4422 0xfa91, 0x1939, 0x637a, 0x4325, 0xc031, 0x3cac,},
4423 {0xe26d, 0xdbde, 0xd05d, 0xb3f6,
4424 0xac7c, 0xe4a0, 0x64bc, 0x467c, 0xddd0, 0x3e55,},
4425 {0x2a20, 0x6224, 0x47b3, 0x98d7,
4426 0x3f23, 0xe9a5, 0xa539, 0xea27, 0xa87f, 0x3f2a,},
4427 {0x0b5b, 0x4af2, 0xa581, 0x18ed,
4428 0x67de, 0x94ba, 0x4539, 0x1ead, 0xcfb1, 0x3f94,},
4429 {0xbf71, 0xa9b3, 0x7989, 0xbe68,
4430 0x4c2e, 0xe15b, 0xc44d, 0x94be, 0xe695, 0x3fc9,},
4431 {0x3d4d, 0x7c3d, 0x36ba, 0x0d2b,
4432 0xfdc2, 0xcefc, 0x8461, 0x7711, 0xabcc, 0x3fe4,},
4433 {0xc155, 0xa4a8, 0x404e, 0x6113,
4434 0xd3c3, 0x652b, 0xe219, 0x1758, 0xd1b7, 0x3ff1,},
4435 {0xd70a, 0x70a3, 0x0a3d, 0xa3d7,
4436 0x3d70, 0xd70a, 0x70a3, 0x0a3d, 0xa3d7, 0x3ff8,},
4437 {0xcccd, 0xcccc, 0xcccc, 0xcccc,
4438 0xcccc, 0xcccc, 0xcccc, 0xcccc, 0xcccc, 0x3ffb,}, /* 10**-1 */
4441 /* LONG_DOUBLE_TYPE_SIZE is other than 128 */
4442 static unsigned EMUSHORT etens
[NTEN
+ 1][NE
] =
4444 {0xc94c, 0x979a, 0x8a20, 0x5202, 0xc460, 0x7525,}, /* 10**4096 */
4445 {0xa74d, 0x5de4, 0xc53d, 0x3b5d, 0x9e8b, 0x5a92,}, /* 10**2048 */
4446 {0x650d, 0x0c17, 0x8175, 0x7586, 0xc976, 0x4d48,},
4447 {0xcc65, 0x91c6, 0xa60e, 0xa0ae, 0xe319, 0x46a3,},
4448 {0xddbc, 0xde8d, 0x9df9, 0xebfb, 0xaa7e, 0x4351,},
4449 {0xc66f, 0x8cdf, 0x80e9, 0x47c9, 0x93ba, 0x41a8,},
4450 {0x3cbf, 0xa6d5, 0xffcf, 0x1f49, 0xc278, 0x40d3,},
4451 {0xf020, 0xb59d, 0x2b70, 0xada8, 0x9dc5, 0x4069,},
4452 {0x0000, 0x0000, 0x0400, 0xc9bf, 0x8e1b, 0x4034,},
4453 {0x0000, 0x0000, 0x0000, 0x2000, 0xbebc, 0x4019,},
4454 {0x0000, 0x0000, 0x0000, 0x0000, 0x9c40, 0x400c,},
4455 {0x0000, 0x0000, 0x0000, 0x0000, 0xc800, 0x4005,},
4456 {0x0000, 0x0000, 0x0000, 0x0000, 0xa000, 0x4002,}, /* 10**1 */
4459 static unsigned EMUSHORT emtens
[NTEN
+ 1][NE
] =
4461 {0x2de4, 0x9fde, 0xd2ce, 0x04c8, 0xa6dd, 0x0ad8,}, /* 10**-4096 */
4462 {0x4925, 0x2de4, 0x3436, 0x534f, 0xceae, 0x256b,}, /* 10**-2048 */
4463 {0x87a6, 0xc0bd, 0xda57, 0x82a5, 0xa2a6, 0x32b5,},
4464 {0x7133, 0xd21c, 0xdb23, 0xee32, 0x9049, 0x395a,},
4465 {0xfa91, 0x1939, 0x637a, 0x4325, 0xc031, 0x3cac,},
4466 {0xac7d, 0xe4a0, 0x64bc, 0x467c, 0xddd0, 0x3e55,},
4467 {0x3f24, 0xe9a5, 0xa539, 0xea27, 0xa87f, 0x3f2a,},
4468 {0x67de, 0x94ba, 0x4539, 0x1ead, 0xcfb1, 0x3f94,},
4469 {0x4c2f, 0xe15b, 0xc44d, 0x94be, 0xe695, 0x3fc9,},
4470 {0xfdc2, 0xcefc, 0x8461, 0x7711, 0xabcc, 0x3fe4,},
4471 {0xd3c3, 0x652b, 0xe219, 0x1758, 0xd1b7, 0x3ff1,},
4472 {0x3d71, 0xd70a, 0x70a3, 0x0a3d, 0xa3d7, 0x3ff8,},
4473 {0xcccd, 0xcccc, 0xcccc, 0xcccc, 0xcccc, 0x3ffb,}, /* 10**-1 */
4477 /* Convert float value X to ASCII string STRING with NDIG digits after
4478 the decimal point. */
4481 e24toasc (x
, string
, ndigs
)
4482 unsigned EMUSHORT x
[];
4486 unsigned EMUSHORT w
[NI
];
4489 etoasc (w
, string
, ndigs
);
4492 /* Convert double value X to ASCII string STRING with NDIG digits after
4493 the decimal point. */
4496 e53toasc (x
, string
, ndigs
)
4497 unsigned EMUSHORT x
[];
4501 unsigned EMUSHORT w
[NI
];
4504 etoasc (w
, string
, ndigs
);
4507 /* Convert double extended value X to ASCII string STRING with NDIG digits
4508 after the decimal point. */
4511 e64toasc (x
, string
, ndigs
)
4512 unsigned EMUSHORT x
[];
4516 unsigned EMUSHORT w
[NI
];
4519 etoasc (w
, string
, ndigs
);
4522 /* Convert 128-bit long double value X to ASCII string STRING with NDIG digits
4523 after the decimal point. */
4526 e113toasc (x
, string
, ndigs
)
4527 unsigned EMUSHORT x
[];
4531 unsigned EMUSHORT w
[NI
];
4534 etoasc (w
, string
, ndigs
);
4537 /* Convert e-type X to ASCII string STRING with NDIGS digits after
4538 the decimal point. */
4540 static char wstring
[80]; /* working storage for ASCII output */
4543 etoasc (x
, string
, ndigs
)
4544 unsigned EMUSHORT x
[];
4549 unsigned EMUSHORT y
[NI
], t
[NI
], u
[NI
], w
[NI
];
4550 unsigned EMUSHORT
*p
, *r
, *ten
;
4551 unsigned EMUSHORT sign
;
4552 int i
, j
, k
, expon
, rndsav
;
4554 unsigned EMUSHORT m
;
4565 sprintf (wstring
, " NaN ");
4569 rndprc
= NBITS
; /* set to full precision */
4570 emov (x
, y
); /* retain external format */
4571 if (y
[NE
- 1] & 0x8000)
4574 y
[NE
- 1] &= 0x7fff;
4581 ten
= &etens
[NTEN
][0];
4583 /* Test for zero exponent */
4586 for (k
= 0; k
< NE
- 1; k
++)
4589 goto tnzro
; /* denormalized number */
4591 goto isone
; /* valid all zeros */
4595 /* Test for infinity. */
4596 if (y
[NE
- 1] == 0x7fff)
4599 sprintf (wstring
, " -Infinity ");
4601 sprintf (wstring
, " Infinity ");
4605 /* Test for exponent nonzero but significand denormalized.
4606 * This is an error condition.
4608 if ((y
[NE
- 1] != 0) && ((y
[NE
- 2] & 0x8000) == 0))
4610 mtherr ("etoasc", DOMAIN
);
4611 sprintf (wstring
, "NaN");
4615 /* Compare to 1.0 */
4624 { /* Number is greater than 1 */
4625 /* Convert significand to an integer and strip trailing decimal zeros. */
4627 u
[NE
- 1] = EXONE
+ NBITS
- 1;
4629 p
= &etens
[NTEN
- 4][0];
4635 for (j
= 0; j
< NE
- 1; j
++)
4648 /* Rescale from integer significand */
4649 u
[NE
- 1] += y
[NE
- 1] - (unsigned int) (EXONE
+ NBITS
- 1);
4651 /* Find power of 10 */
4655 /* An unordered compare result shouldn't happen here. */
4656 while (ecmp (ten
, u
) <= 0)
4658 if (ecmp (p
, u
) <= 0)
4671 { /* Number is less than 1.0 */
4672 /* Pad significand with trailing decimal zeros. */
4675 while ((y
[NE
- 2] & 0x8000) == 0)
4684 for (i
= 0; i
< NDEC
+ 1; i
++)
4686 if ((w
[NI
- 1] & 0x7) != 0)
4688 /* multiply by 10 */
4701 if (eone
[NE
- 1] <= u
[1])
4713 while (ecmp (eone
, w
) > 0)
4715 if (ecmp (p
, w
) >= 0)
4730 /* Find the first (leading) digit. */
4736 digit
= equot
[NI
- 1];
4737 while ((digit
== 0) && (ecmp (y
, ezero
) != 0))
4745 digit
= equot
[NI
- 1];
4753 /* Examine number of digits requested by caller. */
4771 *s
++ = (char)digit
+ '0';
4774 /* Generate digits after the decimal point. */
4775 for (k
= 0; k
<= ndigs
; k
++)
4777 /* multiply current number by 10, without normalizing */
4784 *s
++ = (char) equot
[NI
- 1] + '0';
4786 digit
= equot
[NI
- 1];
4789 /* round off the ASCII string */
4792 /* Test for critical rounding case in ASCII output. */
4796 if (ecmp (t
, ezero
) != 0)
4797 goto roun
; /* round to nearest */
4798 if ((*(s
- 1) & 1) == 0)
4799 goto doexp
; /* round to even */
4801 /* Round up and propagate carry-outs */
4805 /* Carry out to most significant digit? */
4812 /* Most significant digit carries to 10? */
4820 /* Round up and carry out from less significant digits */
4832 sprintf (ss, "e+%d", expon);
4834 sprintf (ss, "e%d", expon);
4836 sprintf (ss
, "e%d", expon
);
4839 /* copy out the working string */
4842 while (*ss
== ' ') /* strip possible leading space */
4844 while ((*s
++ = *ss
++) != '\0')
4849 /* Convert ASCII string to floating point.
4851 Numeric input is a free format decimal number of any length, with
4852 or without decimal point. Entering E after the number followed by an
4853 integer number causes the second number to be interpreted as a power of
4854 10 to be multiplied by the first number (i.e., "scientific" notation). */
4856 /* Convert ASCII string S to single precision float value Y. */
4861 unsigned EMUSHORT
*y
;
4867 /* Convert ASCII string S to double precision value Y. */
4872 unsigned EMUSHORT
*y
;
4874 #if defined(DEC) || defined(IBM)
4882 /* Convert ASCII string S to double extended value Y. */
4887 unsigned EMUSHORT
*y
;
4892 /* Convert ASCII string S to 128-bit long double Y. */
4897 unsigned EMUSHORT
*y
;
4899 asctoeg (s
, y
, 113);
4902 /* Convert ASCII string S to e type Y. */
4907 unsigned EMUSHORT
*y
;
4909 asctoeg (s
, y
, NBITS
);
4912 /* Convert ASCII string SS to e type Y, with a specified rounding precision
4916 asctoeg (ss
, y
, oprec
)
4918 unsigned EMUSHORT
*y
;
4921 unsigned EMUSHORT yy
[NI
], xt
[NI
], tt
[NI
];
4922 int esign
, decflg
, sgnflg
, nexp
, exp
, prec
, lost
;
4923 int k
, trail
, c
, rndsav
;
4925 unsigned EMUSHORT nsign
, *p
;
4926 char *sp
, *s
, *lstr
;
4928 /* Copy the input string. */
4929 lstr
= (char *) alloca (strlen (ss
) + 1);
4931 while (*s
== ' ') /* skip leading spaces */
4934 while ((*sp
++ = *s
++) != '\0')
4939 rndprc
= NBITS
; /* Set to full precision */
4952 if ((k
>= 0) && (k
<= 9))
4954 /* Ignore leading zeros */
4955 if ((prec
== 0) && (decflg
== 0) && (k
== 0))
4957 /* Identify and strip trailing zeros after the decimal point. */
4958 if ((trail
== 0) && (decflg
!= 0))
4961 while ((*sp
>= '0') && (*sp
<= '9'))
4963 /* Check for syntax error */
4965 if ((c
!= 'e') && (c
!= 'E') && (c
!= '\0')
4966 && (c
!= '\n') && (c
!= '\r') && (c
!= ' ')
4977 /* If enough digits were given to more than fill up the yy register,
4978 continuing until overflow into the high guard word yy[2]
4979 guarantees that there will be a roundoff bit at the top
4980 of the low guard word after normalization. */
4985 nexp
+= 1; /* count digits after decimal point */
4986 eshup1 (yy
); /* multiply current number by 10 */
4992 xt
[NI
- 2] = (unsigned EMUSHORT
) k
;
4997 /* Mark any lost non-zero digit. */
4999 /* Count lost digits before the decimal point. */
5014 case '.': /* decimal point */
5044 mtherr ("asctoe", DOMAIN
);
5053 /* Exponent interpretation */
5055 /* 0.0eXXX is zero, regardless of XXX. Check for the 0.0. */
5056 for (k
= 0; k
< NI
; k
++)
5067 /* check for + or - */
5075 while ((*s
>= '0') && (*s
<= '9'))
5079 if (exp
> -(MINDECEXP
))
5089 if (exp
> MAXDECEXP
)
5093 yy
[E
] = 0x7fff; /* infinity */
5096 if (exp
< MINDECEXP
)
5105 /* Pad trailing zeros to minimize power of 10, per IEEE spec. */
5106 while ((nexp
> 0) && (yy
[2] == 0))
5118 if ((k
= enormlz (yy
)) > NBITS
)
5123 lexp
= (EXONE
- 1 + NBITS
) - k
;
5124 emdnorm (yy
, lost
, 0, lexp
, 64);
5126 /* Convert to external format:
5128 Multiply by 10**nexp. If precision is 64 bits,
5129 the maximum relative error incurred in forming 10**n
5130 for 0 <= n <= 324 is 8.2e-20, at 10**180.
5131 For 0 <= n <= 999, the peak relative error is 1.4e-19 at 10**947.
5132 For 0 >= n >= -999, it is -1.55e-19 at 10**-435. */
5147 /* Punt. Can't handle this without 2 divides. */
5148 emovi (etens
[0], tt
);
5155 p
= &etens
[NTEN
][0];
5165 while (exp
<= MAXP
);
5183 /* Round and convert directly to the destination type */
5185 lexp
-= EXONE
- 0x3ff;
5187 else if (oprec
== 24 || oprec
== 56)
5188 lexp
-= EXONE
- (0x41 << 2);
5190 else if (oprec
== 24)
5191 lexp
-= EXONE
- 0177;
5194 else if (oprec
== 56)
5195 lexp
-= EXONE
- 0201;
5198 emdnorm (yy
, k
, 0, lexp
, 64);
5208 todec (yy
, y
); /* see etodec.c */
5213 toibm (yy
, y
, DFmode
);
5236 /* Return Y = largest integer not greater than X (truncated toward minus
5239 static unsigned EMUSHORT bmask
[] =
5262 unsigned EMUSHORT x
[], y
[];
5264 register unsigned EMUSHORT
*p
;
5266 unsigned EMUSHORT f
[NE
];
5268 emov (x
, f
); /* leave in external format */
5269 expon
= (int) f
[NE
- 1];
5270 e
= (expon
& 0x7fff) - (EXONE
- 1);
5276 /* number of bits to clear out */
5288 /* clear the remaining bits */
5290 /* truncate negatives toward minus infinity */
5293 if ((unsigned EMUSHORT
) expon
& (unsigned EMUSHORT
) 0x8000)
5295 for (i
= 0; i
< NE
- 1; i
++)
5307 /* Return S and EXP such that S * 2^EXP = X and .5 <= S < 1.
5308 For example, 1.1 = 0.55 * 2^1. */
5312 unsigned EMUSHORT x
[];
5314 unsigned EMUSHORT s
[];
5316 unsigned EMUSHORT xi
[NI
];
5320 /* Handle denormalized numbers properly using long integer exponent. */
5321 li
= (EMULONG
) ((EMUSHORT
) xi
[1]);
5329 *exp
= (int) (li
- 0x3ffe);
5332 /* Return e type Y = X * 2^PWR2. */
5336 unsigned EMUSHORT x
[];
5338 unsigned EMUSHORT y
[];
5340 unsigned EMUSHORT xi
[NI
];
5348 emdnorm (xi
, i
, i
, li
, 64);
5353 /* C = remainder after dividing B by A, all e type values.
5354 Least significant integer quotient bits left in EQUOT. */
5358 unsigned EMUSHORT a
[], b
[], c
[];
5360 unsigned EMUSHORT den
[NI
], num
[NI
];
5364 || (ecmp (a
, ezero
) == 0)
5372 if (ecmp (a
, ezero
) == 0)
5374 mtherr ("eremain", SING
);
5380 eiremain (den
, num
);
5381 /* Sign of remainder = sign of quotient */
5389 /* Return quotient of exploded e-types NUM / DEN in EQUOT,
5390 remainder in NUM. */
5394 unsigned EMUSHORT den
[], num
[];
5397 unsigned EMUSHORT j
;
5400 ld
-= enormlz (den
);
5402 ln
-= enormlz (num
);
5406 if (ecmpm (den
, num
) <= 0)
5418 emdnorm (num
, 0, 0, ln
, 0);
5421 /* Report an error condition CODE encountered in function NAME.
5422 CODE is one of the following:
5424 Mnemonic Value Significance
5426 DOMAIN 1 argument domain error
5427 SING 2 function singularity
5428 OVERFLOW 3 overflow range error
5429 UNDERFLOW 4 underflow range error
5430 TLOSS 5 total loss of precision
5431 PLOSS 6 partial loss of precision
5432 INVALID 7 NaN - producing operation
5433 EDOM 33 Unix domain error code
5434 ERANGE 34 Unix range error code
5436 The order of appearance of the following messages is bound to the
5437 error codes defined above. */
5440 static char *ermsg
[NMSGS
] =
5442 "unknown", /* error code 0 */
5443 "domain", /* error code 1 */
5444 "singularity", /* et seq. */
5447 "total loss of precision",
5448 "partial loss of precision",
5462 /* The string passed by the calling program is supposed to be the
5463 name of the function in which the error occurred.
5464 The code argument selects which error message string will be printed. */
5466 if ((code
<= 0) || (code
>= NMSGS
))
5468 sprintf (errstr
, " %s %s error", name
, ermsg
[code
]);
5471 /* Set global error message word */
5476 /* Convert DEC double precision D to e type E. */
5480 unsigned EMUSHORT
*d
;
5481 unsigned EMUSHORT
*e
;
5483 unsigned EMUSHORT y
[NI
];
5484 register unsigned EMUSHORT r
, *p
;
5486 ecleaz (y
); /* start with a zero */
5487 p
= y
; /* point to our number */
5488 r
= *d
; /* get DEC exponent word */
5489 if (*d
& (unsigned int) 0x8000)
5490 *p
= 0xffff; /* fill in our sign */
5491 ++p
; /* bump pointer to our exponent word */
5492 r
&= 0x7fff; /* strip the sign bit */
5493 if (r
== 0) /* answer = 0 if high order DEC word = 0 */
5497 r
>>= 7; /* shift exponent word down 7 bits */
5498 r
+= EXONE
- 0201; /* subtract DEC exponent offset */
5499 /* add our e type exponent offset */
5500 *p
++ = r
; /* to form our exponent */
5502 r
= *d
++; /* now do the high order mantissa */
5503 r
&= 0177; /* strip off the DEC exponent and sign bits */
5504 r
|= 0200; /* the DEC understood high order mantissa bit */
5505 *p
++ = r
; /* put result in our high guard word */
5507 *p
++ = *d
++; /* fill in the rest of our mantissa */
5511 eshdn8 (y
); /* shift our mantissa down 8 bits */
5516 /* Convert e type X to DEC double precision D. */
5520 unsigned EMUSHORT
*x
, *d
;
5522 unsigned EMUSHORT xi
[NI
];
5527 /* Adjust exponent for offsets. */
5528 exp
= (EMULONG
) xi
[E
] - (EXONE
- 0201);
5529 /* Round off to nearest or even. */
5532 emdnorm (xi
, 0, 0, exp
, 64);
5537 /* Convert exploded e-type X, that has already been rounded to
5538 56-bit precision, to DEC format double Y. */
5542 unsigned EMUSHORT
*x
, *y
;
5544 unsigned EMUSHORT i
;
5545 unsigned EMUSHORT
*p
;
5584 /* Convert IBM single/double precision to e type. */
5588 unsigned EMUSHORT
*d
;
5589 unsigned EMUSHORT
*e
;
5590 enum machine_mode mode
;
5592 unsigned EMUSHORT y
[NI
];
5593 register unsigned EMUSHORT r
, *p
;
5596 ecleaz (y
); /* start with a zero */
5597 p
= y
; /* point to our number */
5598 r
= *d
; /* get IBM exponent word */
5599 if (*d
& (unsigned int) 0x8000)
5600 *p
= 0xffff; /* fill in our sign */
5601 ++p
; /* bump pointer to our exponent word */
5602 r
&= 0x7f00; /* strip the sign bit */
5603 r
>>= 6; /* shift exponent word down 6 bits */
5604 /* in fact shift by 8 right and 2 left */
5605 r
+= EXONE
- (0x41 << 2); /* subtract IBM exponent offset */
5606 /* add our e type exponent offset */
5607 *p
++ = r
; /* to form our exponent */
5609 *p
++ = *d
++ & 0xff; /* now do the high order mantissa */
5610 /* strip off the IBM exponent and sign bits */
5611 if (mode
!= SFmode
) /* there are only 2 words in SFmode */
5613 *p
++ = *d
++; /* fill in the rest of our mantissa */
5618 if (y
[M
] == 0 && y
[M
+1] == 0 && y
[M
+2] == 0 && y
[M
+3] == 0)
5621 y
[E
] -= 5 + enormlz (y
); /* now normalise the mantissa */
5622 /* handle change in RADIX */
5628 /* Convert e type to IBM single/double precision. */
5632 unsigned EMUSHORT
*x
, *d
;
5633 enum machine_mode mode
;
5635 unsigned EMUSHORT xi
[NI
];
5640 exp
= (EMULONG
) xi
[E
] - (EXONE
- (0x41 << 2)); /* adjust exponent for offsets */
5641 /* round off to nearest or even */
5644 emdnorm (xi
, 0, 0, exp
, 64);
5646 toibm (xi
, d
, mode
);
5651 unsigned EMUSHORT
*x
, *y
;
5652 enum machine_mode mode
;
5654 unsigned EMUSHORT i
;
5655 unsigned EMUSHORT
*p
;
5703 /* Output a binary NaN bit pattern in the target machine's format. */
5705 /* If special NaN bit patterns are required, define them in tm.h
5706 as arrays of unsigned 16-bit shorts. Otherwise, use the default
5712 unsigned EMUSHORT TFbignan
[8] =
5713 {0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
5714 unsigned EMUSHORT TFlittlenan
[8] = {0, 0, 0, 0, 0, 0, 0x8000, 0xffff};
5722 unsigned EMUSHORT XFbignan
[6] =
5723 {0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
5724 unsigned EMUSHORT XFlittlenan
[6] = {0, 0, 0, 0xc000, 0xffff, 0};
5732 unsigned EMUSHORT DFbignan
[4] = {0x7fff, 0xffff, 0xffff, 0xffff};
5733 unsigned EMUSHORT DFlittlenan
[4] = {0, 0, 0, 0xfff8};
5741 unsigned EMUSHORT SFbignan
[2] = {0x7fff, 0xffff};
5742 unsigned EMUSHORT SFlittlenan
[2] = {0, 0xffc0};
5748 make_nan (nan
, sign
, mode
)
5749 unsigned EMUSHORT
*nan
;
5751 enum machine_mode mode
;
5754 unsigned EMUSHORT
*p
;
5758 /* Possibly the `reserved operand' patterns on a VAX can be
5759 used like NaN's, but probably not in the same way as IEEE. */
5760 #if !defined(DEC) && !defined(IBM)
5763 if (REAL_WORDS_BIG_ENDIAN
)
5770 if (REAL_WORDS_BIG_ENDIAN
)
5777 if (REAL_WORDS_BIG_ENDIAN
)
5785 if (REAL_WORDS_BIG_ENDIAN
)
5794 if (REAL_WORDS_BIG_ENDIAN
)
5795 *nan
++ = (sign
<< 15) | *p
++;
5798 if (! REAL_WORDS_BIG_ENDIAN
)
5799 *nan
= (sign
<< 15) | *p
;
5802 /* Convert an SFmode target `float' value to a REAL_VALUE_TYPE.
5803 This is the inverse of the function `etarsingle' invoked by
5804 REAL_VALUE_TO_TARGET_SINGLE. */
5807 ereal_from_float (f
)
5811 unsigned EMUSHORT s
[2];
5812 unsigned EMUSHORT e
[NE
];
5814 /* Convert 32 bit integer to array of 16 bit pieces in target machine order.
5815 This is the inverse operation to what the function `endian' does. */
5816 if (REAL_WORDS_BIG_ENDIAN
)
5818 s
[0] = (unsigned EMUSHORT
) (f
>> 16);
5819 s
[1] = (unsigned EMUSHORT
) f
;
5823 s
[0] = (unsigned EMUSHORT
) f
;
5824 s
[1] = (unsigned EMUSHORT
) (f
>> 16);
5826 /* Convert and promote the target float to E-type. */
5828 /* Output E-type to REAL_VALUE_TYPE. */
5834 /* Convert a DFmode target `double' value to a REAL_VALUE_TYPE.
5835 This is the inverse of the function `etardouble' invoked by
5836 REAL_VALUE_TO_TARGET_DOUBLE.
5838 The DFmode is stored as an array of HOST_WIDE_INT in the target's
5839 data format, with no holes in the bit packing. The first element
5840 of the input array holds the bits that would come first in the
5841 target computer's memory. */
5844 ereal_from_double (d
)
5848 unsigned EMUSHORT s
[4];
5849 unsigned EMUSHORT e
[NE
];
5851 /* Convert array of HOST_WIDE_INT to equivalent array of 16-bit pieces. */
5852 if (REAL_WORDS_BIG_ENDIAN
)
5854 s
[0] = (unsigned EMUSHORT
) (d
[0] >> 16);
5855 s
[1] = (unsigned EMUSHORT
) d
[0];
5856 #if HOST_BITS_PER_WIDE_INT == 32
5857 s
[2] = (unsigned EMUSHORT
) (d
[1] >> 16);
5858 s
[3] = (unsigned EMUSHORT
) d
[1];
5860 /* In this case the entire target double is contained in the
5861 first array element. The second element of the input is
5863 s
[2] = (unsigned EMUSHORT
) (d
[0] >> 48);
5864 s
[3] = (unsigned EMUSHORT
) (d
[0] >> 32);
5869 /* Target float words are little-endian. */
5870 s
[0] = (unsigned EMUSHORT
) d
[0];
5871 s
[1] = (unsigned EMUSHORT
) (d
[0] >> 16);
5872 #if HOST_BITS_PER_WIDE_INT == 32
5873 s
[2] = (unsigned EMUSHORT
) d
[1];
5874 s
[3] = (unsigned EMUSHORT
) (d
[1] >> 16);
5876 s
[2] = (unsigned EMUSHORT
) (d
[0] >> 32);
5877 s
[3] = (unsigned EMUSHORT
) (d
[0] >> 48);
5880 /* Convert target double to E-type. */
5882 /* Output E-type to REAL_VALUE_TYPE. */
5888 /* Convert target computer unsigned 64-bit integer to e-type.
5889 The endian-ness of DImode follows the convention for integers,
5890 so we use WORDS_BIG_ENDIAN here, not REAL_WORDS_BIG_ENDIAN. */
5894 unsigned EMUSHORT
*di
; /* Address of the 64-bit int. */
5895 unsigned EMUSHORT
*e
;
5897 unsigned EMUSHORT yi
[NI
];
5901 if (WORDS_BIG_ENDIAN
)
5903 for (k
= M
; k
< M
+ 4; k
++)
5908 for (k
= M
+ 3; k
>= M
; k
--)
5911 yi
[E
] = EXONE
+ 47; /* exponent if normalize shift count were 0 */
5912 if ((k
= enormlz (yi
)) > NBITS
)/* normalize the significand */
5913 ecleaz (yi
); /* it was zero */
5915 yi
[E
] -= (unsigned EMUSHORT
) k
;/* subtract shift count from exponent */
5919 /* Convert target computer signed 64-bit integer to e-type. */
5923 unsigned EMUSHORT
*di
; /* Address of the 64-bit int. */
5924 unsigned EMUSHORT
*e
;
5926 unsigned EMULONG acc
;
5927 unsigned EMUSHORT yi
[NI
];
5928 unsigned EMUSHORT carry
;
5932 if (WORDS_BIG_ENDIAN
)
5934 for (k
= M
; k
< M
+ 4; k
++)
5939 for (k
= M
+ 3; k
>= M
; k
--)
5942 /* Take absolute value */
5948 for (k
= M
+ 3; k
>= M
; k
--)
5950 acc
= (unsigned EMULONG
) (~yi
[k
] & 0xffff) + carry
;
5957 yi
[E
] = EXONE
+ 47; /* exponent if normalize shift count were 0 */
5958 if ((k
= enormlz (yi
)) > NBITS
)/* normalize the significand */
5959 ecleaz (yi
); /* it was zero */
5961 yi
[E
] -= (unsigned EMUSHORT
) k
;/* subtract shift count from exponent */
5968 /* Convert e-type to unsigned 64-bit int. */
5972 unsigned EMUSHORT
*x
;
5973 unsigned EMUSHORT
*i
;
5975 unsigned EMUSHORT xi
[NI
];
5984 k
= (int) xi
[E
] - (EXONE
- 1);
5987 for (j
= 0; j
< 4; j
++)
5993 for (j
= 0; j
< 4; j
++)
5996 warning ("overflow on truncation to integer");
6001 /* Shift more than 16 bits: first shift up k-16 mod 16,
6002 then shift up by 16's. */
6003 j
= k
- ((k
>> 4) << 4);
6007 if (WORDS_BIG_ENDIAN
)
6018 if (WORDS_BIG_ENDIAN
)
6023 while ((k
-= 16) > 0);
6027 /* shift not more than 16 bits */
6032 if (WORDS_BIG_ENDIAN
)
6051 /* Convert e-type to signed 64-bit int. */
6055 unsigned EMUSHORT
*x
;
6056 unsigned EMUSHORT
*i
;
6058 unsigned EMULONG acc
;
6059 unsigned EMUSHORT xi
[NI
];
6060 unsigned EMUSHORT carry
;
6061 unsigned EMUSHORT
*isave
;
6065 k
= (int) xi
[E
] - (EXONE
- 1);
6068 for (j
= 0; j
< 4; j
++)
6074 for (j
= 0; j
< 4; j
++)
6077 warning ("overflow on truncation to integer");
6083 /* Shift more than 16 bits: first shift up k-16 mod 16,
6084 then shift up by 16's. */
6085 j
= k
- ((k
>> 4) << 4);
6089 if (WORDS_BIG_ENDIAN
)
6100 if (WORDS_BIG_ENDIAN
)
6105 while ((k
-= 16) > 0);
6109 /* shift not more than 16 bits */
6112 if (WORDS_BIG_ENDIAN
)
6128 /* Negate if negative */
6132 if (WORDS_BIG_ENDIAN
)
6134 for (k
= 0; k
< 4; k
++)
6136 acc
= (unsigned EMULONG
) (~(*isave
) & 0xffff) + carry
;
6137 if (WORDS_BIG_ENDIAN
)
6149 /* Longhand square root routine. */
6152 static int esqinited
= 0;
6153 static unsigned short sqrndbit
[NI
];
6157 unsigned EMUSHORT
*x
, *y
;
6159 unsigned EMUSHORT temp
[NI
], num
[NI
], sq
[NI
], xx
[NI
];
6161 int i
, j
, k
, n
, nlups
;
6166 sqrndbit
[NI
- 2] = 1;
6169 /* Check for arg <= 0 */
6170 i
= ecmp (x
, ezero
);
6175 mtherr ("esqrt", DOMAIN
);
6191 /* Bring in the arg and renormalize if it is denormal. */
6193 m
= (EMULONG
) xx
[1]; /* local long word exponent */
6197 /* Divide exponent by 2 */
6199 exp
= (unsigned short) ((m
/ 2) + 0x3ffe);
6201 /* Adjust if exponent odd */
6211 n
= 8; /* get 8 bits of result per inner loop */
6217 /* bring in next word of arg */
6219 num
[NI
- 1] = xx
[j
+ 3];
6220 /* Do additional bit on last outer loop, for roundoff. */
6223 for (i
= 0; i
< n
; i
++)
6225 /* Next 2 bits of arg */
6228 /* Shift up answer */
6230 /* Make trial divisor */
6231 for (k
= 0; k
< NI
; k
++)
6234 eaddm (sqrndbit
, temp
);
6235 /* Subtract and insert answer bit if it goes in */
6236 if (ecmpm (temp
, num
) <= 0)
6246 /* Adjust for extra, roundoff loop done. */
6247 exp
+= (NBITS
- 1) - rndprc
;
6249 /* Sticky bit = 1 if the remainder is nonzero. */
6251 for (i
= 3; i
< NI
; i
++)
6254 /* Renormalize and round off. */
6255 emdnorm (sq
, k
, 0, exp
, 64);
6258 #endif /* EMU_NON_COMPILE not defined */
6260 /* Return the binary precision of the significand for a given
6261 floating point mode. The mode can hold an integer value
6262 that many bits wide, without losing any bits. */
6265 significand_size (mode
)
6266 enum machine_mode mode
;
6269 /* Don't test the modes, but their sizes, lest this
6270 code won't work for BITS_PER_UNIT != 8 . */
6272 switch (GET_MODE_BITSIZE (mode
))
6278 #if TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
6281 #if TARGET_FLOAT_FORMAT == IBM_FLOAT_FORMAT
6284 #if TARGET_FLOAT_FORMAT == VAX_FLOAT_FORMAT