8e97acbbe22ceb96789d36c44b98500f9885154a
[deliverable/linux.git] / arch / mips / math-emu / ieee754.c
1 /* ieee754 floating point arithmetic
2 * single and double precision
3 *
4 * BUGS
5 * not much dp done
6 * doesn't generate IEEE754_INEXACT
7 *
8 */
9 /*
10 * MIPS floating point support
11 * Copyright (C) 1994-2000 Algorithmics Ltd.
12 *
13 * This program is free software; you can distribute it and/or modify it
14 * under the terms of the GNU General Public License (Version 2) as
15 * published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25 */
26
27 #include <linux/compiler.h>
28
29 #include "ieee754.h"
30 #include "ieee754sp.h"
31 #include "ieee754dp.h"
32
33 /*
34 * Special constants
35 */
36
37 /*
38 * Older GCC requires the inner braces for initialization of union ieee754dp's
39 * anonymous struct member. Without an error will result.
40 */
41 #define xPCNST(s, b, m, ebias) \
42 { \
43 { \
44 .sign = (s), \
45 .bexp = (b) + ebias, \
46 .mant = (m) \
47 } \
48 }
49
50 #define DPCNST(s, b, m) \
51 xPCNST(s, b, m, DP_EBIAS)
52
53 const union ieee754dp __ieee754dp_spcvals[] = {
54 DPCNST(0, DP_EMIN - 1, 0x0000000000000ULL), /* + zero */
55 DPCNST(1, DP_EMIN - 1, 0x0000000000000ULL), /* - zero */
56 DPCNST(0, 0, 0x0000000000000ULL), /* + 1.0 */
57 DPCNST(1, 0, 0x0000000000000ULL), /* - 1.0 */
58 DPCNST(0, 3, 0x4000000000000ULL), /* + 10.0 */
59 DPCNST(1, 3, 0x4000000000000ULL), /* - 10.0 */
60 DPCNST(0, DP_EMAX + 1, 0x0000000000000ULL), /* + infinity */
61 DPCNST(1, DP_EMAX + 1, 0x0000000000000ULL), /* - infinity */
62 DPCNST(0, DP_EMAX + 1, 0x7FFFFFFFFFFFFULL), /* + indef quiet Nan */
63 DPCNST(0, DP_EMAX, 0xFFFFFFFFFFFFFULL), /* + max */
64 DPCNST(1, DP_EMAX, 0xFFFFFFFFFFFFFULL), /* - max */
65 DPCNST(0, DP_EMIN, 0x0000000000000ULL), /* + min normal */
66 DPCNST(1, DP_EMIN, 0x0000000000000ULL), /* - min normal */
67 DPCNST(0, DP_EMIN - 1, 0x0000000000001ULL), /* + min denormal */
68 DPCNST(1, DP_EMIN - 1, 0x0000000000001ULL), /* - min denormal */
69 DPCNST(0, 31, 0x0000000000000ULL), /* + 1.0e31 */
70 DPCNST(0, 63, 0x0000000000000ULL), /* + 1.0e63 */
71 };
72
73 #define SPCNST(s, b, m) \
74 xPCNST(s, b, m, SP_EBIAS)
75
76 const union ieee754sp __ieee754sp_spcvals[] = {
77 SPCNST(0, SP_EMIN - 1, 0x000000), /* + zero */
78 SPCNST(1, SP_EMIN - 1, 0x000000), /* - zero */
79 SPCNST(0, 0, 0x000000), /* + 1.0 */
80 SPCNST(1, 0, 0x000000), /* - 1.0 */
81 SPCNST(0, 3, 0x200000), /* + 10.0 */
82 SPCNST(1, 3, 0x200000), /* - 10.0 */
83 SPCNST(0, SP_EMAX + 1, 0x000000), /* + infinity */
84 SPCNST(1, SP_EMAX + 1, 0x000000), /* - infinity */
85 SPCNST(0, SP_EMAX + 1, 0x3FFFFF), /* + indef quiet Nan */
86 SPCNST(0, SP_EMAX, 0x7FFFFF), /* + max normal */
87 SPCNST(1, SP_EMAX, 0x7FFFFF), /* - max normal */
88 SPCNST(0, SP_EMIN, 0x000000), /* + min normal */
89 SPCNST(1, SP_EMIN, 0x000000), /* - min normal */
90 SPCNST(0, SP_EMIN - 1, 0x000001), /* + min denormal */
91 SPCNST(1, SP_EMIN - 1, 0x000001), /* - min denormal */
92 SPCNST(0, 31, 0x000000), /* + 1.0e31 */
93 SPCNST(0, 63, 0x000000), /* + 1.0e63 */
94 };
This page took 0.043525 seconds and 4 git commands to generate.