45{
48 bool signA;
61 bool signRem;
64
65
66
68 uiA = uA.ui;
72 uB.f = b;
73 uiB = uB.ui;
76
77
78 if ( expA == 0x7FF ) {
79 if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
80 goto invalid;
81 }
82 if ( expB == 0x7FF ) {
83 if ( sigB ) goto propagateNaN;
85 }
86
87
88 if ( expA < expB - 1 )
return a;
89
90
91 if ( ! expB ) {
92 if ( ! sigB ) goto invalid;
94 expB = normExpSig.exp;
95 sigB = normExpSig.sig;
96 }
97 if ( ! expA ) {
98 if ( ! sigA )
return a;
100 expA = normExpSig.exp;
101 sigA = normExpSig.sig;
102 }
103
104
105 rem = sigA |
UINT64_C( 0x0010000000000000 );
106 sigB |=
UINT64_C( 0x0010000000000000 );
107 expDiff = expA - expB;
108 if ( expDiff < 1 ) {
109 if ( expDiff < -1 )
return a;
110 sigB <<= 9;
111 if ( expDiff ) {
112 rem <<= 8;
113 q = 0;
114 } else {
115 rem <<= 9;
116 q = (sigB <= rem);
117 if ( q ) rem -= sigB;
118 }
119 } else {
121
122
123
124
125 rem <<= 9;
126 expDiff -= 30;
127
128
129
130
131
132 sigB <<= 9;
133 for (;;) {
135 if ( expDiff < 0 ) break;
136 q = (q64 + 0x80000000)>>32;
137#ifdef SOFTFLOAT_FAST_INT64
138 rem <<= 29;
139#else
141#endif
143 if ( rem &
UINT64_C( 0x8000000000000000 ) ) rem += sigB;
144 expDiff -= 29;
145 }
146
147
148
149 q = (
uint32_t) (q64>>32)>>(~expDiff & 31);
150 rem = (rem<<(expDiff + 30)) - q * (
uint64_t) sigB;
151 if ( rem &
UINT64_C( 0x8000000000000000 ) ) {
152 altRem = rem + sigB;
153 goto selectRem;
154 }
155 }
156
157
158 do {
159 altRem = rem;
160 ++q;
161 rem -= sigB;
162 }
while ( ! (rem &
UINT64_C( 0x8000000000000000 )) );
163 selectRem:
164 meanRem = rem + altRem;
165 if (
166 (meanRem &
UINT64_C( 0x8000000000000000 )) || (! meanRem && (q & 1))
167 ) {
168 rem = altRem;
169 }
170 signRem = signA;
171 if ( rem &
UINT64_C( 0x8000000000000000 ) ) {
172 signRem = ! signRem;
173 rem = -rem;
174 }
176
177
178 propagateNaN:
180 goto uiZ;
181 invalid:
184 uiZ:
185 uZ.ui = uiZ;
186 return uZ.f;
187
188}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
uint_fast64_t softfloat_propagateNaNF64UI(uint_fast64_t uiA, uint_fast64_t uiB)
void softfloat_raiseFlags(uint_fast8_t flags)
struct exp16_sig64 softfloat_normSubnormalF64Sig(uint_fast64_t)
float64_t softfloat_normRoundPackToF64(bool, int_fast16_t, uint_fast64_t)
uint32_t softfloat_approxRecip32_1(uint32_t a)
unsigned __int64 uint64_t