45{
46 union ui128_f128 uA;
48 bool signA;
50 struct uint128 sigA, uiZ;
51 struct exp32_sig128 normExpSig;
54 struct uint128 rem;
58 struct uint128
y, term;
60 struct uint128 sigZ;
61 union ui128_f128 uZ;
62
63
64
66 uiA64 = uA.ui.v64;
67 uiA0 = uA.ui.v0;
68 signA = signF128UI64( uiA64 );
69 expA = expF128UI64( uiA64 );
70 sigA.v64 = fracF128UI64( uiA64 );
71 sigA.v0 = uiA0;
72
73
74 if ( expA == 0x7FFF ) {
75 if ( sigA.v64 | sigA.v0 ) {
77 goto uiZ;
78 }
79 if ( ! signA )
return a;
80 goto invalid;
81 }
82
83
84 if ( signA ) {
85 if ( ! (expA | sigA.v64 | sigA.v0) )
return a;
86 goto invalid;
87 }
88
89
90 if ( ! expA ) {
91 if ( ! (sigA.v64 | sigA.v0) )
return a;
93 expA = normExpSig.exp;
94 sigA = normExpSig.sig;
95 }
96
97
98
99
100
101 expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
102 expA &= 1;
103 sigA.v64 |=
UINT64_C( 0x0001000000000000 );
104 sig32A = sigA.v64>>17;
107 if ( expA ) {
108 sig32Z >>= 1;
110 } else {
112 }
113 qs[2] = sig32Z;
115
116
121
122
123
124 for (;;) {
127 if ( ! (rem.v64 &
UINT64_C( 0x8000000000000000 )) )
break;
128 --q;
129 sig64Z -= 1<<3;
130 }
131 qs[1] = q;
132
133
134 q = ((rem.v64>>2) * recipSqrt32)>>32;
136 sig64Z <<= 1;
137
138
139
140 for (;;) {
145 if ( ! (rem.v64 &
UINT64_C( 0x8000000000000000 )) )
break;
146 --q;
147 }
148 qs[0] = q;
149
150
151 q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
154 sigZ =
157 term.v64, term.v0
158 );
159
160
161 if ( (q & 0xF) <= 2 ) {
162 q &= ~3;
165 y.v0 |= sigZExtra>>58;
172
173
174
175
176 if ( term.v64 &
UINT64_C( 0x8000000000000000 ) ) {
177 sigZExtra |= 1;
178 } else {
179 if ( term.v64 | term.v0 |
y.v0 ) {
180 if ( sigZExtra ) {
181 --sigZExtra;
182 } else {
184 sigZExtra = ~0;
185 }
186 }
187 }
188 }
190
191
192 invalid:
196 uiZ:
197 uZ.ui = uiZ;
198 return uZ.f;
199
200}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
struct uint128 softfloat_propagateNaNF128UI(uint_fast64_t uiA64, uint_fast64_t uiA0, uint_fast64_t uiB64, uint_fast64_t uiB0)
void softfloat_raiseFlags(uint_fast8_t flags)
#define defaultNaNF128UI64
#define defaultNaNF128UI0
uint32_t softfloat_approxRecipSqrt32_1(unsigned int oddExpA, uint32_t a)
struct uint128 softfloat_add128(uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0)
struct uint128 softfloat_mul128By32(uint64_t a64, uint64_t a0, uint32_t b)
struct uint128 softfloat_mul64ByShifted32To128(uint64_t a, uint32_t b)
struct exp32_sig128 softfloat_normSubnormalF128Sig(uint_fast64_t sig64, uint_fast64_t sig0)
float128_t softfloat_roundPackToF128(bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0, uint_fast64_t sigExtra)
struct uint128 softfloat_shortShiftLeft128(uint64_t a64, uint64_t a0, uint_fast8_t dist)
struct uint128 softfloat_sub128(uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0)
unsigned __int64 uint64_t