1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include <linux/types.h>
29#include <linux/printk.h>
30#include "ieee754.h"
31#include "ieee754sp.h"
32#include "ieee754dp.h"
33
34union ieee754dp ieee754dp_dump(char *m, union ieee754dp x)
35{
36 int i;
37
38 printk("%s", m);
39 printk("<%08x,%08x>\n", (unsigned) (x.bits >> 32),
40 (unsigned) x.bits);
41 printk("\t=");
42 switch (ieee754dp_class(x)) {
43 case IEEE754_CLASS_QNAN:
44 case IEEE754_CLASS_SNAN:
45 printk("Nan %c", DPSIGN(x) ? '-' : '+');
46 for (i = DP_FBITS - 1; i >= 0; i--)
47 printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
48 break;
49 case IEEE754_CLASS_INF:
50 printk("%cInfinity", DPSIGN(x) ? '-' : '+');
51 break;
52 case IEEE754_CLASS_ZERO:
53 printk("%cZero", DPSIGN(x) ? '-' : '+');
54 break;
55 case IEEE754_CLASS_DNORM:
56 printk("%c0.", DPSIGN(x) ? '-' : '+');
57 for (i = DP_FBITS - 1; i >= 0; i--)
58 printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
59 printk("e%d", DPBEXP(x) - DP_EBIAS);
60 break;
61 case IEEE754_CLASS_NORM:
62 printk("%c1.", DPSIGN(x) ? '-' : '+');
63 for (i = DP_FBITS - 1; i >= 0; i--)
64 printk("%c", DPMANT(x) & DP_MBIT(i) ? '1' : '0');
65 printk("e%d", DPBEXP(x) - DP_EBIAS);
66 break;
67 default:
68 printk("Illegal/Unknown IEEE754 value class");
69 }
70 printk("\n");
71 return x;
72}
73
74union ieee754sp ieee754sp_dump(char *m, union ieee754sp x)
75{
76 int i;
77
78 printk("%s=", m);
79 printk("<%08x>\n", (unsigned) x.bits);
80 printk("\t=");
81 switch (ieee754sp_class(x)) {
82 case IEEE754_CLASS_QNAN:
83 case IEEE754_CLASS_SNAN:
84 printk("Nan %c", SPSIGN(x) ? '-' : '+');
85 for (i = SP_FBITS - 1; i >= 0; i--)
86 printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
87 break;
88 case IEEE754_CLASS_INF:
89 printk("%cInfinity", SPSIGN(x) ? '-' : '+');
90 break;
91 case IEEE754_CLASS_ZERO:
92 printk("%cZero", SPSIGN(x) ? '-' : '+');
93 break;
94 case IEEE754_CLASS_DNORM:
95 printk("%c0.", SPSIGN(x) ? '-' : '+');
96 for (i = SP_FBITS - 1; i >= 0; i--)
97 printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
98 printk("e%d", SPBEXP(x) - SP_EBIAS);
99 break;
100 case IEEE754_CLASS_NORM:
101 printk("%c1.", SPSIGN(x) ? '-' : '+');
102 for (i = SP_FBITS - 1; i >= 0; i--)
103 printk("%c", SPMANT(x) & SP_MBIT(i) ? '1' : '0');
104 printk("e%d", SPBEXP(x) - SP_EBIAS);
105 break;
106 default:
107 printk("Illegal/Unknown IEEE754 value class");
108 }
109 printk("\n");
110 return x;
111}
112