1 /* ieee754 floating point arithmetic
2 * single and double precision
6 * doesn't generate IEEE754_INEXACT
10 * MIPS floating point support
11 * Copyright (C) 1994-2000 Algorithmics Ltd.
12 * http://www.algor.co.uk
14 * ########################################################################
16 * This program is free software; you can distribute it and/or modify it
17 * under the terms of the GNU General Public License (Version 2) as
18 * published by the Free Software Foundation.
20 * This program is distributed in the hope it will be useful, but WITHOUT
21 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
29 * ########################################################################
33 #include "ieee754int.h"
36 #define DP_EMIN (-1022)
40 #define SP_EMIN (-126)
43 /* indexed by class */
44 const char *const ieee754_cname[] = {
57 #if (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN) || defined(__MIPSEL__)
58 #define SPSTR(s,b,m) {m,b,s}
59 #define DPSTR(s,b,mh,ml) {ml,mh,b,s}
63 #define SPSTR(s,b,m) {s,b,m}
64 #define DPSTR(s,b,mh,ml) {s,b,mh,ml}
67 const struct ieee754dp_konst __ieee754dp_spcvals[] = {
68 DPSTR(0, DP_EMIN - 1 + DP_EBIAS, 0, 0), /* + zero */
69 DPSTR(1, DP_EMIN - 1 + DP_EBIAS, 0, 0), /* - zero */
70 DPSTR(0, DP_EBIAS, 0, 0), /* + 1.0 */
71 DPSTR(1, DP_EBIAS, 0, 0), /* - 1.0 */
72 DPSTR(0, 3 + DP_EBIAS, 0x40000, 0), /* + 10.0 */
73 DPSTR(1, 3 + DP_EBIAS, 0x40000, 0), /* - 10.0 */
74 DPSTR(0, DP_EMAX + 1 + DP_EBIAS, 0, 0), /* + infinity */
75 DPSTR(1, DP_EMAX + 1 + DP_EBIAS, 0, 0), /* - infinity */
76 DPSTR(0,DP_EMAX+1+DP_EBIAS,0x7FFFF,0xFFFFFFFF), /* + indef quiet Nan */
77 DPSTR(0, DP_EMAX + DP_EBIAS, 0xFFFFF, 0xFFFFFFFF), /* + max */
78 DPSTR(1, DP_EMAX + DP_EBIAS, 0xFFFFF, 0xFFFFFFFF), /* - max */
79 DPSTR(0, DP_EMIN + DP_EBIAS, 0, 0), /* + min normal */
80 DPSTR(1, DP_EMIN + DP_EBIAS, 0, 0), /* - min normal */
81 DPSTR(0, DP_EMIN - 1 + DP_EBIAS, 0, 1), /* + min denormal */
82 DPSTR(1, DP_EMIN - 1 + DP_EBIAS, 0, 1), /* - min denormal */
83 DPSTR(0, 31 + DP_EBIAS, 0, 0), /* + 1.0e31 */
84 DPSTR(0, 63 + DP_EBIAS, 0, 0), /* + 1.0e63 */
87 const struct ieee754sp_konst __ieee754sp_spcvals[] = {
88 SPSTR(0, SP_EMIN - 1 + SP_EBIAS, 0), /* + zero */
89 SPSTR(1, SP_EMIN - 1 + SP_EBIAS, 0), /* - zero */
90 SPSTR(0, SP_EBIAS, 0), /* + 1.0 */
91 SPSTR(1, SP_EBIAS, 0), /* - 1.0 */
92 SPSTR(0, 3 + SP_EBIAS, 0x200000), /* + 10.0 */
93 SPSTR(1, 3 + SP_EBIAS, 0x200000), /* - 10.0 */
94 SPSTR(0, SP_EMAX + 1 + SP_EBIAS, 0), /* + infinity */
95 SPSTR(1, SP_EMAX + 1 + SP_EBIAS, 0), /* - infinity */
96 SPSTR(0,SP_EMAX+1+SP_EBIAS,0x3FFFFF), /* + indef quiet Nan */
97 SPSTR(0, SP_EMAX + SP_EBIAS, 0x7FFFFF), /* + max normal */
98 SPSTR(1, SP_EMAX + SP_EBIAS, 0x7FFFFF), /* - max normal */
99 SPSTR(0, SP_EMIN + SP_EBIAS, 0), /* + min normal */
100 SPSTR(1, SP_EMIN + SP_EBIAS, 0), /* - min normal */
101 SPSTR(0, SP_EMIN - 1 + SP_EBIAS, 1), /* + min denormal */
102 SPSTR(1, SP_EMIN - 1 + SP_EBIAS, 1), /* - min denormal */
103 SPSTR(0, 31 + SP_EBIAS, 0), /* + 1.0e31 */
104 SPSTR(0, 63 + SP_EBIAS, 0), /* + 1.0e63 */
108 int ieee754si_xcpt(int r, const char *op, ...)
110 struct ieee754xctx ax;
115 ax.rt = IEEE754_RT_SI;
122 s64 ieee754di_xcpt(s64 r, const char *op, ...)
124 struct ieee754xctx ax;
129 ax.rt = IEEE754_RT_DI;