Lines Matching +full:x +full:- +full:y

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (C) 1994-2000 Algorithmics Ltd.
20 union ieee754dp ieee754dp_sqrt(union ieee754dp x) in ieee754dp_sqrt() argument
23 union ieee754dp y, z, t; in ieee754dp_sqrt() local
31 /* x == INF or NAN? */ in ieee754dp_sqrt()
34 return ieee754dp_nanxcpt(x); in ieee754dp_sqrt()
38 return x; in ieee754dp_sqrt()
42 return x; in ieee754dp_sqrt()
46 /* sqrt(-Inf) = Nan */ in ieee754dp_sqrt()
51 return x; in ieee754dp_sqrt()
58 /* sqrt(-x) = Nan */ in ieee754dp_sqrt()
73 if (xe > 512) { /* x > 2**-512? */ in ieee754dp_sqrt()
74 xe -= 512; /* x = x / 2**512 */ in ieee754dp_sqrt()
76 } else if (xe < -512) { /* x < 2**-512? */ in ieee754dp_sqrt()
77 xe += 512; /* x = x * 2**512 */ in ieee754dp_sqrt()
78 scalx -= 256; in ieee754dp_sqrt()
81 x = builddp(0, xe + DP_EBIAS, xm & ~DP_HIDDEN_BIT); in ieee754dp_sqrt()
82 y = x; in ieee754dp_sqrt()
85 yh = y.bits >> 32; in ieee754dp_sqrt()
87 yh = yh - table[(yh >> 15) & 31]; in ieee754dp_sqrt()
88 y.bits = ((u64) yh << 32) | (y.bits & 0xffffffff); in ieee754dp_sqrt()
91 /* t=x/y; y=y+t; py[n0]=py[n0]-0x00100006; py[n1]=0; */ in ieee754dp_sqrt()
92 t = ieee754dp_div(x, y); in ieee754dp_sqrt()
93 y = ieee754dp_add(y, t); in ieee754dp_sqrt()
94 y.bits -= 0x0010000600000000LL; in ieee754dp_sqrt()
95 y.bits &= 0xffffffff00000000LL; in ieee754dp_sqrt()
97 /* triple to almost 56 sig. bits: y ~= sqrt(x) to within 1 ulp */ in ieee754dp_sqrt()
98 /* t=y*y; z=t; pt[n0]+=0x00100000; t+=z; z=(x-z)*y; */ in ieee754dp_sqrt()
99 t = ieee754dp_mul(y, y); in ieee754dp_sqrt()
103 z = ieee754dp_mul(ieee754dp_sub(x, z), y); in ieee754dp_sqrt()
105 /* t=z/(t+x) ; pt[n0]+=0x00100000; y+=t; */ in ieee754dp_sqrt()
106 t = ieee754dp_div(z, ieee754dp_add(t, x)); in ieee754dp_sqrt()
108 y = ieee754dp_add(y, t); in ieee754dp_sqrt()
110 /* twiddle last bit to force y correctly rounded */ in ieee754dp_sqrt()
116 /* t=x/y; ...chopped quotient, possibly inexact */ in ieee754dp_sqrt()
117 t = ieee754dp_div(x, y); in ieee754dp_sqrt()
119 if (ieee754_csr.sx & IEEE754_INEXACT || t.bits != y.bits) { in ieee754dp_sqrt()
122 /* t = t-ulp */ in ieee754dp_sqrt()
123 t.bits -= 1; in ieee754dp_sqrt()
131 y.bits += 1; in ieee754dp_sqrt()
138 /* y=y+t; ...chopped sum */ in ieee754dp_sqrt()
139 y = ieee754dp_add(y, t); in ieee754dp_sqrt()
141 /* adjust scalx for correctly rounded sqrt(x) */ in ieee754dp_sqrt()
142 scalx -= 1; in ieee754dp_sqrt()
145 /* py[n0]=py[n0]+scalx; ...scale back y */ in ieee754dp_sqrt()
146 y.bexp += scalx; in ieee754dp_sqrt()
151 return y; in ieee754dp_sqrt()