summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/cephes/etodec.c
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2012-07-13 17:49:56 +0000
committercvs2svn <admin@example.com>2012-07-13 17:49:56 +0000
commit6f82d0e8f9756938f04071892206a5af85e676f0 (patch)
tree821921a1dd0a5a3cece91121e121cc63c4b68128 /src/regress/lib/libc/cephes/etodec.c
parent9204e59073bcf27e1487ec4ac46e981902ddd904 (diff)
downloadopenbsd-eric_g2k12.tar.gz
openbsd-eric_g2k12.tar.bz2
openbsd-eric_g2k12.zip
This commit was manufactured by cvs2git to create tag 'eric_g2k12'.eric_g2k12
Diffstat (limited to 'src/regress/lib/libc/cephes/etodec.c')
-rw-r--r--src/regress/lib/libc/cephes/etodec.c199
1 files changed, 0 insertions, 199 deletions
diff --git a/src/regress/lib/libc/cephes/etodec.c b/src/regress/lib/libc/cephes/etodec.c
deleted file mode 100644
index a15845efb6..0000000000
--- a/src/regress/lib/libc/cephes/etodec.c
+++ /dev/null
@@ -1,199 +0,0 @@
1/* $OpenBSD: etodec.c,v 1.1 2011/07/02 18:11:01 martynas Exp $ */
2
3/*
4 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include "ehead.h"
20void emovi(), emovo(), ecleaz(), eshdn8(), emdnorm();
21void todec();
22/*
23; convert DEC double precision to e type
24; double d;
25; short e[NE];
26; dectoe( &d, e );
27*/
28void dectoe( d, e )
29unsigned short *d;
30unsigned short *e;
31{
32unsigned short y[NI];
33register unsigned short r, *p;
34
35ecleaz(y); /* start with a zero */
36p = y; /* point to our number */
37r = *d; /* get DEC exponent word */
38if( *d & (unsigned int )0x8000 )
39 *p = 0xffff; /* fill in our sign */
40++p; /* bump pointer to our exponent word */
41r &= 0x7fff; /* strip the sign bit */
42if( r == 0 ) /* answer = 0 if high order DEC word = 0 */
43 goto done;
44
45
46r >>= 7; /* shift exponent word down 7 bits */
47r += EXONE - 0201; /* subtract DEC exponent offset */
48 /* add our e type exponent offset */
49*p++ = r; /* to form our exponent */
50
51r = *d++; /* now do the high order mantissa */
52r &= 0177; /* strip off the DEC exponent and sign bits */
53r |= 0200; /* the DEC understood high order mantissa bit */
54*p++ = r; /* put result in our high guard word */
55
56*p++ = *d++; /* fill in the rest of our mantissa */
57*p++ = *d++;
58*p = *d;
59
60eshdn8(y); /* shift our mantissa down 8 bits */
61done:
62emovo( y, e );
63}
64
65
66
67/*
68; convert e type to DEC double precision
69; double d;
70; short e[NE];
71; etodec( e, &d );
72*/
73#if 0
74static unsigned short decbit[NI] = {0,0,0,0,0,0,0200,0};
75void etodec( x, d )
76unsigned short *x, *d;
77{
78unsigned short xi[NI];
79register unsigned short r;
80int i, j;
81
82emovi( x, xi );
83*d = 0;
84if( xi[0] != 0 )
85 *d = 0100000;
86r = xi[E];
87if( r < (EXONE - 128) )
88 goto zout;
89i = xi[M+4];
90if( (i & 0200) != 0 )
91 {
92 if( (i & 0377) == 0200 )
93 {
94 if( (i & 0400) != 0 )
95 {
96 /* check all less significant bits */
97 for( j=M+5; j<NI; j++ )
98 {
99 if( xi[j] != 0 )
100 goto yesrnd;
101 }
102 }
103 goto nornd;
104 }
105yesrnd:
106 eaddm( decbit, xi );
107 r -= enormlz(xi);
108 }
109
110nornd:
111
112r -= EXONE;
113r += 0201;
114if( r < 0 )
115 {
116zout:
117 *d++ = 0;
118 *d++ = 0;
119 *d++ = 0;
120 *d++ = 0;
121 return;
122 }
123if( r >= 0377 )
124 {
125 *d++ = 077777;
126 *d++ = -1;
127 *d++ = -1;
128 *d++ = -1;
129 return;
130 }
131r &= 0377;
132r <<= 7;
133eshup8( xi );
134xi[M] &= 0177;
135r |= xi[M];
136*d++ |= r;
137*d++ = xi[M+1];
138*d++ = xi[M+2];
139*d++ = xi[M+3];
140}
141#else
142
143extern int rndprc;
144
145void etodec( x, d )
146unsigned short *x, *d;
147{
148unsigned short xi[NI];
149long exp;
150int rndsav;
151
152emovi( x, xi );
153exp = (long )xi[E] - (EXONE - 0201); /* adjust exponent for offsets */
154/* round off to nearest or even */
155rndsav = rndprc;
156rndprc = 56;
157emdnorm( xi, 0, 0, exp, 64 );
158rndprc = rndsav;
159todec( xi, d );
160}
161
162void todec( x, y )
163unsigned short *x, *y;
164{
165unsigned short i;
166unsigned short *p;
167
168p = x;
169*y = 0;
170if( *p++ )
171 *y = 0100000;
172i = *p++;
173if( i == 0 )
174 {
175 *y++ = 0;
176 *y++ = 0;
177 *y++ = 0;
178 *y++ = 0;
179 return;
180 }
181if( i > 0377 )
182 {
183 *y++ |= 077777;
184 *y++ = 0xffff;
185 *y++ = 0xffff;
186 *y++ = 0xffff;
187 return;
188 }
189i &= 0377;
190i <<= 7;
191eshup8( x );
192x[M] &= 0177;
193i |= x[M];
194*y++ |= i;
195*y++ = x[M+1];
196*y++ = x[M+2];
197*y++ = x[M+3];
198}
199#endif