Go to the documentation of this file.
26 #define Dbl_firstword(value) Dallp1(value)
27 #define Dbl_secondword(value) Dallp2(value)
28 #define Dbl_thirdword(value) dummy_location
29 #define Dbl_fourthword(value) dummy_location
31 #define Dbl_sign(object) Dsign(object)
32 #define Dbl_exponent(object) Dexponent(object)
33 #define Dbl_signexponent(object) Dsignexponent(object)
34 #define Dbl_mantissap1(object) Dmantissap1(object)
35 #define Dbl_mantissap2(object) Dmantissap2(object)
36 #define Dbl_exponentmantissap1(object) Dexponentmantissap1(object)
37 #define Dbl_allp1(object) Dallp1(object)
38 #define Dbl_allp2(object) Dallp2(object)
42 #define Dbl_and_signs( src1dst, src2) \
43 Dallp1(src1dst) = (Dallp1(src2)|~((unsigned int)1<<31)) & Dallp1(src1dst)
44 #define Dbl_or_signs( src1dst, src2) \
45 Dallp1(src1dst) = (Dallp1(src2)&((unsigned int)1<<31)) | Dallp1(src1dst)
48 #define Dbl_clear_exponent_set_hidden(srcdst) Deposit_dexponent(srcdst,1)
49 #define Dbl_clear_signexponent_set_hidden(srcdst) \
50 Deposit_dsignexponent(srcdst,1)
51 #define Dbl_clear_sign(srcdst) Dallp1(srcdst) &= ~((unsigned int)1<<31)
52 #define Dbl_clear_signexponent(srcdst) \
53 Dallp1(srcdst) &= Dmantissap1((unsigned int)-1)
64 #define Dbl_rightshift(srcdstA, srcdstB, varamount) \
65 {if((varamount) >= 32) { \
66 Dallp2(srcdstB) = Dallp1(srcdstA) >> (varamount-32); \
69 else if(varamount > 0) { \
70 Variable_shift_double(Dallp1(srcdstA), Dallp2(srcdstB), \
71 (varamount), Dallp2(srcdstB)); \
72 Dallp1(srcdstA) >>= varamount; \
75 #define Dbl_rightshift_exponentmantissa(srcdstA, srcdstB, varamount) \
76 {if((varamount) >= 32) { \
77 Dallp2(srcdstB) = Dexponentmantissap1(srcdstA) >> (varamount-32); \
78 Dallp1(srcdstA) &= ((unsigned int)1<<31); \
80 else if(varamount > 0) { \
81 Variable_shift_double(Dexponentmantissap1(srcdstA), Dallp2(srcdstB), \
82 (varamount), Dallp2(srcdstB)); \
83 Deposit_dexponentmantissap1(srcdstA, \
84 (Dexponentmantissap1(srcdstA)>>varamount)); \
87 #define Dbl_leftshift(srcdstA, srcdstB, varamount) \
88 {if((varamount) >= 32) { \
89 Dallp1(srcdstA) = Dallp2(srcdstB) << (varamount-32); \
93 if ((varamount) > 0) { \
94 Dallp1(srcdstA) = (Dallp1(srcdstA) << (varamount)) | \
95 (Dallp2(srcdstB) >> (32-(varamount))); \
96 Dallp2(srcdstB) <<= varamount; \
99 #define Dbl_leftshiftby1_withextent(lefta,leftb,right,resulta,resultb) \
100 Shiftdouble(Dallp1(lefta), Dallp2(leftb), 31, Dallp1(resulta)); \
101 Shiftdouble(Dallp2(leftb), Extall(right), 31, Dallp2(resultb))
103 #define Dbl_rightshiftby1_withextent(leftb,right,dst) \
104 Extall(dst) = (Dallp2(leftb) << 31) | ((unsigned int)Extall(right) >> 1) | \
107 #define Dbl_arithrightshiftby1(srcdstA,srcdstB) \
108 Shiftdouble(Dallp1(srcdstA),Dallp2(srcdstB),1,Dallp2(srcdstB));\
109 Dallp1(srcdstA) = (int)Dallp1(srcdstA) >> 1
112 #define Dbl_signextendedsign(value) Dsignedsign(value)
114 #define Dbl_isone_hidden(dbl_value) (Is_dhidden(dbl_value)!=0)
117 #define Dbl_increment(dbl_valueA,dbl_valueB) \
118 if( (Dallp2(dbl_valueB) += 1) == 0 ) Dallp1(dbl_valueA) += 1
119 #define Dbl_increment_mantissa(dbl_valueA,dbl_valueB) \
120 if( (Dmantissap2(dbl_valueB) += 1) == 0 ) \
121 Deposit_dmantissap1(dbl_valueA,dbl_valueA+1)
122 #define Dbl_decrement(dbl_valueA,dbl_valueB) \
123 if( Dallp2(dbl_valueB) == 0 ) Dallp1(dbl_valueA) -= 1; \
124 Dallp2(dbl_valueB) -= 1
126 #define Dbl_isone_sign(dbl_value) (Is_dsign(dbl_value)!=0)
127 #define Dbl_isone_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)!=0)
128 #define Dbl_isone_lowmantissap1(dbl_valueA) (Is_dlowp1(dbl_valueA)!=0)
129 #define Dbl_isone_lowmantissap2(dbl_valueB) (Is_dlowp2(dbl_valueB)!=0)
130 #define Dbl_isone_signaling(dbl_value) (Is_dsignaling(dbl_value)!=0)
131 #define Dbl_is_signalingnan(dbl_value) (Dsignalingnan(dbl_value)==0xfff)
132 #define Dbl_isnotzero(dbl_valueA,dbl_valueB) \
133 (Dallp1(dbl_valueA) || Dallp2(dbl_valueB))
134 #define Dbl_isnotzero_hiddenhigh7mantissa(dbl_value) \
135 (Dhiddenhigh7mantissa(dbl_value)!=0)
136 #define Dbl_isnotzero_exponent(dbl_value) (Dexponent(dbl_value)!=0)
137 #define Dbl_isnotzero_mantissa(dbl_valueA,dbl_valueB) \
138 (Dmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB))
139 #define Dbl_isnotzero_mantissap1(dbl_valueA) (Dmantissap1(dbl_valueA)!=0)
140 #define Dbl_isnotzero_mantissap2(dbl_valueB) (Dmantissap2(dbl_valueB)!=0)
141 #define Dbl_isnotzero_exponentmantissa(dbl_valueA,dbl_valueB) \
142 (Dexponentmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB))
143 #define Dbl_isnotzero_low4p2(dbl_value) (Dlow4p2(dbl_value)!=0)
144 #define Dbl_iszero(dbl_valueA,dbl_valueB) (Dallp1(dbl_valueA)==0 && \
145 Dallp2(dbl_valueB)==0)
146 #define Dbl_iszero_allp1(dbl_value) (Dallp1(dbl_value)==0)
147 #define Dbl_iszero_allp2(dbl_value) (Dallp2(dbl_value)==0)
148 #define Dbl_iszero_hidden(dbl_value) (Is_dhidden(dbl_value)==0)
149 #define Dbl_iszero_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)==0)
150 #define Dbl_iszero_hiddenhigh3mantissa(dbl_value) \
151 (Dhiddenhigh3mantissa(dbl_value)==0)
152 #define Dbl_iszero_hiddenhigh7mantissa(dbl_value) \
153 (Dhiddenhigh7mantissa(dbl_value)==0)
154 #define Dbl_iszero_sign(dbl_value) (Is_dsign(dbl_value)==0)
155 #define Dbl_iszero_exponent(dbl_value) (Dexponent(dbl_value)==0)
156 #define Dbl_iszero_mantissa(dbl_valueA,dbl_valueB) \
157 (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
158 #define Dbl_iszero_exponentmantissa(dbl_valueA,dbl_valueB) \
159 (Dexponentmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
160 #define Dbl_isinfinity_exponent(dbl_value) \
161 (Dexponent(dbl_value)==DBL_INFINITY_EXPONENT)
162 #define Dbl_isnotinfinity_exponent(dbl_value) \
163 (Dexponent(dbl_value)!=DBL_INFINITY_EXPONENT)
164 #define Dbl_isinfinity(dbl_valueA,dbl_valueB) \
165 (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT && \
166 Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
167 #define Dbl_isnan(dbl_valueA,dbl_valueB) \
168 (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT && \
169 (Dmantissap1(dbl_valueA)!=0 || Dmantissap2(dbl_valueB)!=0))
170 #define Dbl_isnotnan(dbl_valueA,dbl_valueB) \
171 (Dexponent(dbl_valueA)!=DBL_INFINITY_EXPONENT || \
172 (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0))
174 #define Dbl_islessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
175 (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) || \
176 (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \
177 Dallp2(dbl_op1b) < Dallp2(dbl_op2b)))
178 #define Dbl_isgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
179 (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) || \
180 (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \
181 Dallp2(dbl_op1b) > Dallp2(dbl_op2b)))
182 #define Dbl_isnotlessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
183 (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) || \
184 (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \
185 Dallp2(dbl_op1b) >= Dallp2(dbl_op2b)))
186 #define Dbl_isnotgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
187 (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) || \
188 (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \
189 Dallp2(dbl_op1b) <= Dallp2(dbl_op2b)))
190 #define Dbl_isequal(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
191 ((Dallp1(dbl_op1a) == Dallp1(dbl_op2a)) && \
192 (Dallp2(dbl_op1b) == Dallp2(dbl_op2b)))
194 #define Dbl_leftshiftby8(dbl_valueA,dbl_valueB) \
195 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),24,Dallp1(dbl_valueA)); \
196 Dallp2(dbl_valueB) <<= 8
197 #define Dbl_leftshiftby7(dbl_valueA,dbl_valueB) \
198 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),25,Dallp1(dbl_valueA)); \
199 Dallp2(dbl_valueB) <<= 7
200 #define Dbl_leftshiftby4(dbl_valueA,dbl_valueB) \
201 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),28,Dallp1(dbl_valueA)); \
202 Dallp2(dbl_valueB) <<= 4
203 #define Dbl_leftshiftby3(dbl_valueA,dbl_valueB) \
204 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),29,Dallp1(dbl_valueA)); \
205 Dallp2(dbl_valueB) <<= 3
206 #define Dbl_leftshiftby2(dbl_valueA,dbl_valueB) \
207 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),30,Dallp1(dbl_valueA)); \
208 Dallp2(dbl_valueB) <<= 2
209 #define Dbl_leftshiftby1(dbl_valueA,dbl_valueB) \
210 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),31,Dallp1(dbl_valueA)); \
211 Dallp2(dbl_valueB) <<= 1
213 #define Dbl_rightshiftby8(dbl_valueA,dbl_valueB) \
214 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),8,Dallp2(dbl_valueB)); \
215 Dallp1(dbl_valueA) >>= 8
216 #define Dbl_rightshiftby4(dbl_valueA,dbl_valueB) \
217 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),4,Dallp2(dbl_valueB)); \
218 Dallp1(dbl_valueA) >>= 4
219 #define Dbl_rightshiftby2(dbl_valueA,dbl_valueB) \
220 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),2,Dallp2(dbl_valueB)); \
221 Dallp1(dbl_valueA) >>= 2
222 #define Dbl_rightshiftby1(dbl_valueA,dbl_valueB) \
223 Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),1,Dallp2(dbl_valueB)); \
224 Dallp1(dbl_valueA) >>= 1
236 #define Dbl_ismagnitudeless(leftB,rightB,signlessleft,signlessright) \
237 ((signlessleft <= signlessright) && \
238 ( (signlessleft < signlessright) || (Dallp2(leftB)<Dallp2(rightB)) ))
240 #define Dbl_copytoint_exponentmantissap1(src,dest) \
241 dest = Dexponentmantissap1(src)
245 #define Dbl_set_quiet(dbl_value) Deposit_dhigh2mantissa(dbl_value,1)
246 #define Dbl_set_exponent(dbl_value, exp) Deposit_dexponent(dbl_value,exp)
248 #define Dbl_set_mantissa(desta,destb,valuea,valueb) \
249 Deposit_dmantissap1(desta,valuea); \
250 Dmantissap2(destb) = Dmantissap2(valueb)
251 #define Dbl_set_mantissap1(desta,valuea) \
252 Deposit_dmantissap1(desta,valuea)
253 #define Dbl_set_mantissap2(destb,valueb) \
254 Dmantissap2(destb) = Dmantissap2(valueb)
256 #define Dbl_set_exponentmantissa(desta,destb,valuea,valueb) \
257 Deposit_dexponentmantissap1(desta,valuea); \
258 Dmantissap2(destb) = Dmantissap2(valueb)
259 #define Dbl_set_exponentmantissap1(dest,value) \
260 Deposit_dexponentmantissap1(dest,value)
262 #define Dbl_copyfromptr(src,desta,destb) \
263 Dallp1(desta) = src->wd0; \
264 Dallp2(destb) = src->wd1
265 #define Dbl_copytoptr(srca,srcb,dest) \
266 dest->wd0 = Dallp1(srca); \
267 dest->wd1 = Dallp2(srcb)
270 #define Dbl_setinfinity_exponent(dbl_value) \
271 Deposit_dexponent(dbl_value,DBL_INFINITY_EXPONENT)
272 #define Dbl_setinfinity_exponentmantissa(dbl_valueA,dbl_valueB) \
273 Deposit_dexponentmantissap1(dbl_valueA, \
274 (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH)))); \
275 Dmantissap2(dbl_valueB) = 0
276 #define Dbl_setinfinitypositive(dbl_valueA,dbl_valueB) \
278 = (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \
279 Dmantissap2(dbl_valueB) = 0
280 #define Dbl_setinfinitynegative(dbl_valueA,dbl_valueB) \
281 Dallp1(dbl_valueA) = ((unsigned int)1<<31) | \
282 (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \
283 Dmantissap2(dbl_valueB) = 0
284 #define Dbl_setinfinity(dbl_valueA,dbl_valueB,sign) \
285 Dallp1(dbl_valueA) = ((unsigned int)sign << 31) | \
286 (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \
287 Dmantissap2(dbl_valueB) = 0
289 #define Dbl_sethigh4bits(dbl_value, extsign) Deposit_dhigh4p1(dbl_value,extsign)
290 #define Dbl_set_sign(dbl_value,sign) Deposit_dsign(dbl_value,sign)
291 #define Dbl_invert_sign(dbl_value) Deposit_dsign(dbl_value,~Dsign(dbl_value))
292 #define Dbl_setone_sign(dbl_value) Deposit_dsign(dbl_value,1)
293 #define Dbl_setone_lowmantissap2(dbl_value) Deposit_dlowp2(dbl_value,1)
294 #define Dbl_setzero_sign(dbl_value) Dallp1(dbl_value) &= 0x7fffffff
295 #define Dbl_setzero_exponent(dbl_value) \
296 Dallp1(dbl_value) &= 0x800fffff
297 #define Dbl_setzero_mantissa(dbl_valueA,dbl_valueB) \
298 Dallp1(dbl_valueA) &= 0xfff00000; \
299 Dallp2(dbl_valueB) = 0
300 #define Dbl_setzero_mantissap1(dbl_value) Dallp1(dbl_value) &= 0xfff00000
301 #define Dbl_setzero_mantissap2(dbl_value) Dallp2(dbl_value) = 0
302 #define Dbl_setzero_exponentmantissa(dbl_valueA,dbl_valueB) \
303 Dallp1(dbl_valueA) &= 0x80000000; \
304 Dallp2(dbl_valueB) = 0
305 #define Dbl_setzero_exponentmantissap1(dbl_valueA) \
306 Dallp1(dbl_valueA) &= 0x80000000
307 #define Dbl_setzero(dbl_valueA,dbl_valueB) \
308 Dallp1(dbl_valueA) = 0; Dallp2(dbl_valueB) = 0
309 #define Dbl_setzerop1(dbl_value) Dallp1(dbl_value) = 0
310 #define Dbl_setzerop2(dbl_value) Dallp2(dbl_value) = 0
311 #define Dbl_setnegativezero(dbl_value) \
312 Dallp1(dbl_value) = (unsigned int)1 << 31; Dallp2(dbl_value) = 0
313 #define Dbl_setnegativezerop1(dbl_value) Dallp1(dbl_value) = (unsigned int)1<<31
318 #define Dbl_setwrapped_exponent(dbl_value,exponent,op) \
319 Deposit_dexponent(dbl_value,(exponent op DBL_WRAP))
321 #define Dbl_setlargestpositive(dbl_valueA,dbl_valueB) \
322 Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \
323 | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ); \
324 Dallp2(dbl_valueB) = 0xFFFFFFFF
325 #define Dbl_setlargestnegative(dbl_valueA,dbl_valueB) \
326 Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \
327 | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ) \
328 | ((unsigned int)1<<31); \
329 Dallp2(dbl_valueB) = 0xFFFFFFFF
330 #define Dbl_setlargest_exponentmantissa(dbl_valueA,dbl_valueB) \
331 Deposit_dexponentmantissap1(dbl_valueA, \
332 (((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \
333 | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ))); \
334 Dallp2(dbl_valueB) = 0xFFFFFFFF
336 #define Dbl_setnegativeinfinity(dbl_valueA,dbl_valueB) \
337 Dallp1(dbl_valueA) = ((1<<DBL_EXP_LENGTH) | DBL_INFINITY_EXPONENT) \
338 << (32-(1+DBL_EXP_LENGTH)) ; \
339 Dallp2(dbl_valueB) = 0
340 #define Dbl_setlargest(dbl_valueA,dbl_valueB,sign) \
341 Dallp1(dbl_valueA) = ((unsigned int)sign << 31) | \
342 ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) | \
343 ((1 << (32-(1+DBL_EXP_LENGTH))) - 1 ); \
344 Dallp2(dbl_valueB) = 0xFFFFFFFF
348 #define Dbl_right_align(srcdstA,srcdstB,shift,extent) \
357 Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB), \
358 shift-32, Extall(extent)); \
359 if(Dallp2(srcdstB) << 64 - (shift)) Ext_setone_low(extent); \
361 else Extall(extent) = Dallp2(srcdstB); \
362 Dallp2(srcdstB) = Dallp1(srcdstA) >> (shift - 32); \
366 Extall(extent) = Dallp1(srcdstA); \
367 if(Dallp2(srcdstB)) Ext_setone_low(extent); \
368 Dallp2(srcdstB) = 0; \
370 Dallp1(srcdstA) = 0; \
377 Extall(extent) = Dallp2(srcdstB) << 32 - (shift); \
378 Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB),shift, \
380 Dallp1(srcdstA) >>= shift; \
382 else Extall(extent) = 0; \
389 #define Dbl_fix_overshift(srcdstA,srcdstB,shift,extent) \
390 Extall(extent) = Dallp2(srcdstB) << 32 - (shift); \
391 Dallp2(srcdstB) = (Dallp1(srcdstA) << 32 - (shift)) | \
392 (Dallp2(srcdstB) >> (shift)); \
393 Dallp1(srcdstA) = Dallp1(srcdstA) >> shift
395 #define Dbl_hiddenhigh3mantissa(dbl_value) Dhiddenhigh3mantissa(dbl_value)
396 #define Dbl_hidden(dbl_value) Dhidden(dbl_value)
397 #define Dbl_lowmantissap2(dbl_value) Dlowp2(dbl_value)
400 #define Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb) \
401 if( Dallp2(rightb) > Dallp2(leftb) ) Dallp1(lefta)--; \
402 Dallp2(resultb) = Dallp2(leftb) - Dallp2(rightb); \
403 Dallp1(resulta) = Dallp1(lefta) - Dallp1(righta)
407 #define Dbl_subtract_withextension(lefta,leftb,righta,rightb,extent,resulta,resultb) \
408 Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb); \
409 if( (Extall(extent) = 0-Extall(extent)) ) \
411 if((Dallp2(resultb)--) == 0) Dallp1(resulta)--; \
414 #define Dbl_addition(lefta,leftb,righta,rightb,resulta,resultb) \
417 Dallp1(resulta) = Dallp1(lefta) + Dallp1(righta); \
418 if((Dallp2(resultb) = Dallp2(leftb) + Dallp2(rightb)) < Dallp2(rightb)) \
421 #define Dbl_xortointp1(left,right,result) \
422 result = Dallp1(left) XOR Dallp1(right)
424 #define Dbl_xorfromintp1(left,right,result) \
425 Dallp1(result) = left XOR Dallp1(right)
427 #define Dbl_swap_lower(left,right) \
428 Dallp2(left) = Dallp2(left) XOR Dallp2(right); \
429 Dallp2(right) = Dallp2(left) XOR Dallp2(right); \
430 Dallp2(left) = Dallp2(left) XOR Dallp2(right)
433 #define Dbl_makequietnan(desta,destb) \
434 Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH)) \
435 | (1<<(32-(1+DBL_EXP_LENGTH+2))); \
437 #define Dbl_makesignalingnan(desta,destb) \
438 Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH)) \
439 | (1<<(32-(1+DBL_EXP_LENGTH+1))); \
442 #define Dbl_normalize(dbl_opndA,dbl_opndB,exponent) \
443 while(Dbl_iszero_hiddenhigh7mantissa(dbl_opndA)) { \
444 Dbl_leftshiftby8(dbl_opndA,dbl_opndB); \
447 if(Dbl_iszero_hiddenhigh3mantissa(dbl_opndA)) { \
448 Dbl_leftshiftby4(dbl_opndA,dbl_opndB); \
451 while(Dbl_iszero_hidden(dbl_opndA)) { \
452 Dbl_leftshiftby1(dbl_opndA,dbl_opndB); \
456 #define Twoword_add(src1dstA,src1dstB,src2A,src2B) \
462 if ((src1dstB) + (src2B) < (src1dstB)) Dallp1(src1dstA)++; \
463 Dallp1(src1dstA) += (src2A); \
464 Dallp2(src1dstB) += (src2B)
466 #define Twoword_subtract(src1dstA,src1dstB,src2A,src2B) \
472 if ((src1dstB) < (src2B)) Dallp1(src1dstA)--; \
473 Dallp1(src1dstA) -= (src2A); \
474 Dallp2(src1dstB) -= (src2B)
476 #define Dbl_setoverflow(resultA,resultB) \
478 switch (Rounding_mode()) { \
480 if (Dbl_isone_sign(resultA)) { \
481 Dbl_setlargestnegative(resultA,resultB); \
484 Dbl_setinfinitypositive(resultA,resultB); \
488 if (Dbl_iszero_sign(resultA)) { \
489 Dbl_setlargestpositive(resultA,resultB); \
492 Dbl_setinfinitynegative(resultA,resultB); \
496 Dbl_setinfinity_exponentmantissa(resultA,resultB); \
499 Dbl_setlargest_exponentmantissa(resultA,resultB); \
502 #define Dbl_denormalize(opndp1,opndp2,exponent,guard,sticky,inexact) \
503 Dbl_clear_signexponent_set_hidden(opndp1); \
504 if (exponent >= (1-DBL_P)) { \
505 if (exponent >= -31) { \
506 guard = (Dallp2(opndp2) >> -exponent) & 1; \
507 if (exponent < 0) sticky |= Dallp2(opndp2) << (32+exponent); \
508 if (exponent > -31) { \
509 Variable_shift_double(opndp1,opndp2,1-exponent,opndp2); \
510 Dallp1(opndp1) >>= 1-exponent; \
513 Dallp2(opndp2) = Dallp1(opndp1); \
514 Dbl_setzerop1(opndp1); \
518 guard = (Dallp1(opndp1) >> -32-exponent) & 1; \
519 if (exponent == -32) sticky |= Dallp2(opndp2); \
520 else sticky |= (Dallp2(opndp2) | Dallp1(opndp1) << 64+exponent); \
521 Dallp2(opndp2) = Dallp1(opndp1) >> -31-exponent; \
522 Dbl_setzerop1(opndp1); \
524 inexact = guard | sticky; \
528 sticky |= (Dallp1(opndp1) | Dallp2(opndp2)); \
529 Dbl_setzero(opndp1,opndp2); \
537 #define DBLEXT_THRESHOLD 106
539 #define Dblext_setzero(valA,valB,valC,valD) \
540 Dextallp1(valA) = 0; Dextallp2(valB) = 0; \
541 Dextallp3(valC) = 0; Dextallp4(valD) = 0
544 #define Dblext_isnotzero_mantissap3(valC) (Dextallp3(valC)!=0)
545 #define Dblext_isnotzero_mantissap4(valD) (Dextallp3(valD)!=0)
546 #define Dblext_isone_lowp2(val) (Dextlowp2(val)!=0)
547 #define Dblext_isone_highp3(val) (Dexthighp3(val)!=0)
548 #define Dblext_isnotzero_low31p3(val) (Dextlow31p3(val)!=0)
549 #define Dblext_iszero(valA,valB,valC,valD) (Dextallp1(valA)==0 && \
550 Dextallp2(valB)==0 && Dextallp3(valC)==0 && Dextallp4(valD)==0)
552 #define Dblext_copy(srca,srcb,srcc,srcd,desta,destb,destc,destd) \
553 Dextallp1(desta) = Dextallp4(srca); \
554 Dextallp2(destb) = Dextallp4(srcb); \
555 Dextallp3(destc) = Dextallp4(srcc); \
556 Dextallp4(destd) = Dextallp4(srcd)
558 #define Dblext_swap_lower(leftp2,leftp3,leftp4,rightp2,rightp3,rightp4) \
559 Dextallp2(leftp2) = Dextallp2(leftp2) XOR Dextallp2(rightp2); \
560 Dextallp2(rightp2) = Dextallp2(leftp2) XOR Dextallp2(rightp2); \
561 Dextallp2(leftp2) = Dextallp2(leftp2) XOR Dextallp2(rightp2); \
562 Dextallp3(leftp3) = Dextallp3(leftp3) XOR Dextallp3(rightp3); \
563 Dextallp3(rightp3) = Dextallp3(leftp3) XOR Dextallp3(rightp3); \
564 Dextallp3(leftp3) = Dextallp3(leftp3) XOR Dextallp3(rightp3); \
565 Dextallp4(leftp4) = Dextallp4(leftp4) XOR Dextallp4(rightp4); \
566 Dextallp4(rightp4) = Dextallp4(leftp4) XOR Dextallp4(rightp4); \
567 Dextallp4(leftp4) = Dextallp4(leftp4) XOR Dextallp4(rightp4)
569 #define Dblext_setone_lowmantissap4(dbl_value) Deposit_dextlowp4(dbl_value,1)
572 #define Dblext_right_align(srcdstA,srcdstB,srcdstC,srcdstD,shift) \
573 {int shiftamt, sticky; \
574 shiftamt = shift % 32; \
576 switch (shift/32) { \
577 case 0: if (shiftamt > 0) { \
578 sticky = Dextallp4(srcdstD) << 32 - (shiftamt); \
579 Variable_shift_double(Dextallp3(srcdstC), \
580 Dextallp4(srcdstD),shiftamt,Dextallp4(srcdstD)); \
581 Variable_shift_double(Dextallp2(srcdstB), \
582 Dextallp3(srcdstC),shiftamt,Dextallp3(srcdstC)); \
583 Variable_shift_double(Dextallp1(srcdstA), \
584 Dextallp2(srcdstB),shiftamt,Dextallp2(srcdstB)); \
585 Dextallp1(srcdstA) >>= shiftamt; \
588 case 1: if (shiftamt > 0) { \
589 sticky = (Dextallp3(srcdstC) << 31 - shiftamt) | \
590 Dextallp4(srcdstD); \
591 Variable_shift_double(Dextallp2(srcdstB), \
592 Dextallp3(srcdstC),shiftamt,Dextallp4(srcdstD)); \
593 Variable_shift_double(Dextallp1(srcdstA), \
594 Dextallp2(srcdstB),shiftamt,Dextallp3(srcdstC)); \
597 sticky = Dextallp4(srcdstD); \
598 Dextallp4(srcdstD) = Dextallp3(srcdstC); \
599 Dextallp3(srcdstC) = Dextallp2(srcdstB); \
601 Dextallp2(srcdstB) = Dextallp1(srcdstA) >> shiftamt; \
602 Dextallp1(srcdstA) = 0; \
604 case 2: if (shiftamt > 0) { \
605 sticky = (Dextallp2(srcdstB) << 31 - shiftamt) | \
606 Dextallp3(srcdstC) | Dextallp4(srcdstD); \
607 Variable_shift_double(Dextallp1(srcdstA), \
608 Dextallp2(srcdstB),shiftamt,Dextallp4(srcdstD)); \
611 sticky = Dextallp3(srcdstC) | Dextallp4(srcdstD); \
612 Dextallp4(srcdstD) = Dextallp2(srcdstB); \
614 Dextallp3(srcdstC) = Dextallp1(srcdstA) >> shiftamt; \
615 Dextallp1(srcdstA) = Dextallp2(srcdstB) = 0; \
617 case 3: if (shiftamt > 0) { \
618 sticky = (Dextallp1(srcdstA) << 31 - shiftamt) | \
619 Dextallp2(srcdstB) | Dextallp3(srcdstC) | \
620 Dextallp4(srcdstD); \
623 sticky = Dextallp2(srcdstB) | Dextallp3(srcdstC) | \
624 Dextallp4(srcdstD); \
626 Dextallp4(srcdstD) = Dextallp1(srcdstA) >> shiftamt; \
627 Dextallp1(srcdstA) = Dextallp2(srcdstB) = 0; \
628 Dextallp3(srcdstC) = 0; \
631 if (sticky) Dblext_setone_lowmantissap4(srcdstD); \
635 #define Dblext_subtract(lefta,leftb,leftc,leftd,righta,rightb,rightc,rightd,resulta,resultb,resultc,resultd) \
636 if( Dextallp4(rightd) > Dextallp4(leftd) ) \
637 if( (Dextallp3(leftc)--) == 0) \
638 if( (Dextallp2(leftb)--) == 0) Dextallp1(lefta)--; \
639 Dextallp4(resultd) = Dextallp4(leftd) - Dextallp4(rightd); \
640 if( Dextallp3(rightc) > Dextallp3(leftc) ) \
641 if( (Dextallp2(leftb)--) == 0) Dextallp1(lefta)--; \
642 Dextallp3(resultc) = Dextallp3(leftc) - Dextallp3(rightc); \
643 if( Dextallp2(rightb) > Dextallp2(leftb) ) Dextallp1(lefta)--; \
644 Dextallp2(resultb) = Dextallp2(leftb) - Dextallp2(rightb); \
645 Dextallp1(resulta) = Dextallp1(lefta) - Dextallp1(righta)
647 #define Dblext_addition(lefta,leftb,leftc,leftd,righta,rightb,rightc,rightd,resulta,resultb,resultc,resultd) \
650 if ((Dextallp4(resultd) = Dextallp4(leftd)+Dextallp4(rightd)) < \
652 if((Dextallp3(resultc) = Dextallp3(leftc)+Dextallp3(rightc)+1) <= \
654 if((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)+1) \
655 <= Dextallp2(rightb)) \
656 Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \
657 else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \
659 if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)) < \
661 Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \
662 else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \
664 if ((Dextallp3(resultc) = Dextallp3(leftc)+Dextallp3(rightc)) < \
666 if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)+1) \
667 <= Dextallp2(rightb)) \
668 Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \
669 else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \
671 if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)) < \
673 Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \
674 else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)
677 #define Dblext_arithrightshiftby1(srcdstA,srcdstB,srcdstC,srcdstD) \
678 Shiftdouble(Dextallp3(srcdstC),Dextallp4(srcdstD),1,Dextallp4(srcdstD)); \
679 Shiftdouble(Dextallp2(srcdstB),Dextallp3(srcdstC),1,Dextallp3(srcdstC)); \
680 Shiftdouble(Dextallp1(srcdstA),Dextallp2(srcdstB),1,Dextallp2(srcdstB)); \
681 Dextallp1(srcdstA) = (int)Dextallp1(srcdstA) >> 1
683 #define Dblext_leftshiftby8(valA,valB,valC,valD) \
684 Shiftdouble(Dextallp1(valA),Dextallp2(valB),24,Dextallp1(valA)); \
685 Shiftdouble(Dextallp2(valB),Dextallp3(valC),24,Dextallp2(valB)); \
686 Shiftdouble(Dextallp3(valC),Dextallp4(valD),24,Dextallp3(valC)); \
687 Dextallp4(valD) <<= 8
688 #define Dblext_leftshiftby4(valA,valB,valC,valD) \
689 Shiftdouble(Dextallp1(valA),Dextallp2(valB),28,Dextallp1(valA)); \
690 Shiftdouble(Dextallp2(valB),Dextallp3(valC),28,Dextallp2(valB)); \
691 Shiftdouble(Dextallp3(valC),Dextallp4(valD),28,Dextallp3(valC)); \
692 Dextallp4(valD) <<= 4
693 #define Dblext_leftshiftby3(valA,valB,valC,valD) \
694 Shiftdouble(Dextallp1(valA),Dextallp2(valB),29,Dextallp1(valA)); \
695 Shiftdouble(Dextallp2(valB),Dextallp3(valC),29,Dextallp2(valB)); \
696 Shiftdouble(Dextallp3(valC),Dextallp4(valD),29,Dextallp3(valC)); \
697 Dextallp4(valD) <<= 3
698 #define Dblext_leftshiftby2(valA,valB,valC,valD) \
699 Shiftdouble(Dextallp1(valA),Dextallp2(valB),30,Dextallp1(valA)); \
700 Shiftdouble(Dextallp2(valB),Dextallp3(valC),30,Dextallp2(valB)); \
701 Shiftdouble(Dextallp3(valC),Dextallp4(valD),30,Dextallp3(valC)); \
702 Dextallp4(valD) <<= 2
703 #define Dblext_leftshiftby1(valA,valB,valC,valD) \
704 Shiftdouble(Dextallp1(valA),Dextallp2(valB),31,Dextallp1(valA)); \
705 Shiftdouble(Dextallp2(valB),Dextallp3(valC),31,Dextallp2(valB)); \
706 Shiftdouble(Dextallp3(valC),Dextallp4(valD),31,Dextallp3(valC)); \
707 Dextallp4(valD) <<= 1
709 #define Dblext_rightshiftby4(valueA,valueB,valueC,valueD) \
710 Shiftdouble(Dextallp3(valueC),Dextallp4(valueD),4,Dextallp4(valueD)); \
711 Shiftdouble(Dextallp2(valueB),Dextallp3(valueC),4,Dextallp3(valueC)); \
712 Shiftdouble(Dextallp1(valueA),Dextallp2(valueB),4,Dextallp2(valueB)); \
713 Dextallp1(valueA) >>= 4
714 #define Dblext_rightshiftby1(valueA,valueB,valueC,valueD) \
715 Shiftdouble(Dextallp3(valueC),Dextallp4(valueD),1,Dextallp4(valueD)); \
716 Shiftdouble(Dextallp2(valueB),Dextallp3(valueC),1,Dextallp3(valueC)); \
717 Shiftdouble(Dextallp1(valueA),Dextallp2(valueB),1,Dextallp2(valueB)); \
718 Dextallp1(valueA) >>= 1
720 #define Dblext_xortointp1(left,right,result) Dbl_xortointp1(left,right,result)
722 #define Dblext_xorfromintp1(left,right,result) \
723 Dbl_xorfromintp1(left,right,result)
725 #define Dblext_copytoint_exponentmantissap1(src,dest) \
726 Dbl_copytoint_exponentmantissap1(src,dest)
728 #define Dblext_ismagnitudeless(leftB,rightB,signlessleft,signlessright) \
729 Dbl_ismagnitudeless(leftB,rightB,signlessleft,signlessright)
731 #define Dbl_copyto_dblext(src1,src2,dest1,dest2,dest3,dest4) \
732 Dextallp1(dest1) = Dallp1(src1); Dextallp2(dest2) = Dallp2(src2); \
733 Dextallp3(dest3) = 0; Dextallp4(dest4) = 0
735 #define Dblext_set_sign(dbl_value,sign) Dbl_set_sign(dbl_value,sign)
736 #define Dblext_clear_signexponent_set_hidden(srcdst) \
737 Dbl_clear_signexponent_set_hidden(srcdst)
738 #define Dblext_clear_signexponent(srcdst) Dbl_clear_signexponent(srcdst)
739 #define Dblext_clear_sign(srcdst) Dbl_clear_sign(srcdst)
740 #define Dblext_isone_hidden(dbl_value) Dbl_isone_hidden(dbl_value)
747 #define Fourword_add(src1dstA,src1dstB,src1dstC,src1dstD,src2A,src2B,src2C,src2D) \
755 if ((unsigned int)(src1dstD += (src2D)) < (unsigned int)(src2D)) { \
756 if ((unsigned int)(src1dstC += (src2C) + 1) <= \
757 (unsigned int)(src2C)) { \
758 if ((unsigned int)(src1dstB += (src2B) + 1) <= \
759 (unsigned int)(src2B)) src1dstA++; \
761 else if ((unsigned int)(src1dstB += (src2B)) < \
762 (unsigned int)(src2B)) src1dstA++; \
765 if ((unsigned int)(src1dstC += (src2C)) < \
766 (unsigned int)(src2C)) { \
767 if ((unsigned int)(src1dstB += (src2B) + 1) <= \
768 (unsigned int)(src2B)) src1dstA++; \
770 else if ((unsigned int)(src1dstB += (src2B)) < \
771 (unsigned int)(src2B)) src1dstA++; \
775 #define Dblext_denormalize(opndp1,opndp2,opndp3,opndp4,exponent,is_tiny) \
776 {int shiftamt, sticky; \
778 if (exponent == 0 && (Dextallp3(opndp3) || Dextallp4(opndp4))) { \
779 switch (Rounding_mode()) { \
781 if (Dbl_iszero_sign(opndp1)) { \
782 Dbl_increment(opndp1,opndp2); \
783 if (Dbl_isone_hiddenoverflow(opndp1)) \
785 Dbl_decrement(opndp1,opndp2); \
789 if (Dbl_isone_sign(opndp1)) { \
790 Dbl_increment(opndp1,opndp2); \
791 if (Dbl_isone_hiddenoverflow(opndp1)) \
793 Dbl_decrement(opndp1,opndp2); \
797 if (Dblext_isone_highp3(opndp3) && \
798 (Dblext_isone_lowp2(opndp2) || \
799 Dblext_isnotzero_low31p3(opndp3))) { \
800 Dbl_increment(opndp1,opndp2); \
801 if (Dbl_isone_hiddenoverflow(opndp1)) \
803 Dbl_decrement(opndp1,opndp2); \
808 Dblext_clear_signexponent_set_hidden(opndp1); \
809 if (exponent >= (1-QUAD_P)) { \
810 shiftamt = (1-exponent) % 32; \
811 switch((1-exponent)/32) { \
812 case 0: sticky = Dextallp4(opndp4) << 32-(shiftamt); \
813 Variableshiftdouble(opndp3,opndp4,shiftamt,opndp4); \
814 Variableshiftdouble(opndp2,opndp3,shiftamt,opndp3); \
815 Variableshiftdouble(opndp1,opndp2,shiftamt,opndp2); \
816 Dextallp1(opndp1) >>= shiftamt; \
818 case 1: sticky = (Dextallp3(opndp3) << 32-(shiftamt)) | \
820 Variableshiftdouble(opndp2,opndp3,shiftamt,opndp4); \
821 Variableshiftdouble(opndp1,opndp2,shiftamt,opndp3); \
822 Dextallp2(opndp2) = Dextallp1(opndp1) >> shiftamt; \
823 Dextallp1(opndp1) = 0; \
825 case 2: sticky = (Dextallp2(opndp2) << 32-(shiftamt)) | \
826 Dextallp3(opndp3) | Dextallp4(opndp4); \
827 Variableshiftdouble(opndp1,opndp2,shiftamt,opndp4); \
828 Dextallp3(opndp3) = Dextallp1(opndp1) >> shiftamt; \
829 Dextallp1(opndp1) = Dextallp2(opndp2) = 0; \
831 case 3: sticky = (Dextallp1(opndp1) << 32-(shiftamt)) | \
832 Dextallp2(opndp2) | Dextallp3(opndp3) | \
834 Dextallp4(opndp4) = Dextallp1(opndp1) >> shiftamt; \
835 Dextallp1(opndp1) = Dextallp2(opndp2) = 0; \
836 Dextallp3(opndp3) = 0; \
841 sticky = Dextallp1(opndp1) | Dextallp2(opndp2) | \
842 Dextallp3(opndp3) | Dextallp4(opndp4); \
843 Dblext_setzero(opndp1,opndp2,opndp3,opndp4); \
845 if (sticky) Dblext_setone_lowmantissap4(opndp4); \