51{
53 bool roundNearEven;
54 uint64_t sig, roundIncrement, roundMask, roundBits;
55 bool isTiny;
57 bool doIncrement;
58
59
60
63 sig =
66 if ( roundingPrecision == 80 ) goto precision80;
67 if ( roundingPrecision == 64 ) {
68 roundIncrement =
UINT64_C( 0x0000000000000400 );
69 roundMask =
UINT64_C( 0x00000000000007FF );
70 } else if ( roundingPrecision == 32 ) {
71 roundIncrement =
UINT64_C( 0x0000008000000000 );
72 roundMask =
UINT64_C( 0x000000FFFFFFFFFF );
73 } else {
74 goto precision80;
75 }
76
77
80 roundIncrement =
81 (roundingMode
83 ? roundMask
84 : 0;
85 }
86 roundBits = sig & roundMask;
87
88
89 if ( 0x7FFD <= (
uint32_t) (exp - 1) ) {
90 if ( exp <= 0 ) {
91
92
93 isTiny =
96 || (exp < 0)
97 || (sig <= (
uint64_t) (sig + roundIncrement));
99 roundBits = sig & roundMask;
100 if ( roundBits ) {
103#ifdef SOFTFLOAT_ROUND_ODD
105 sig |= roundMask + 1;
106 }
107#endif
108 }
109 sig += roundIncrement;
110 exp = ((sig &
UINT64_C( 0x8000000000000000 )) != 0);
111 roundIncrement = roundMask + 1;
112 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
113 roundMask |= roundIncrement;
114 }
115 sig &= ~roundMask;
116 goto packReturn;
117 }
118 if (
119 (0x7FFE < exp)
120 || ((exp == 0x7FFE) && ((
uint64_t) (sig + roundIncrement) < sig))
121 ) {
123 }
124 }
125
126
127 if ( roundBits ) {
129#ifdef SOFTFLOAT_ROUND_ODD
131 sig = (sig & ~roundMask) | (roundMask + 1);
132 goto packReturn;
133 }
134#endif
135 }
136 sig += roundIncrement;
137 if ( sig < roundIncrement ) {
138 ++exp;
139 sig =
UINT64_C( 0x8000000000000000 );
140 }
141 roundIncrement = roundMask + 1;
142 if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
143 roundMask |= roundIncrement;
144 }
145 sig &= ~roundMask;
146 goto packReturn;
147
148
149 precision80:
151 doIncrement = (0x80000000 <= sigExtra);
153 doIncrement =
154 (roundingMode
156 && sigExtra;
157 }
158
159
160 if ( 0x7FFD <= (
uint32_t) (exp - 1) ) {
161 if ( exp <= 0 ) {
162
163
164 isTiny =
167 || (exp < 0)
168 || ! doIncrement
169 || (sig <
UINT64_C( 0xFFFFFFFFFFFFFFFF ));
171 exp = 0;
172 sig =
176 if ( sigExtra ) {
179#ifdef SOFTFLOAT_ROUND_ODD
181 sig |= 1;
182 goto packReturn;
183 }
184#endif
185 }
186 doIncrement = (0x80000000 <= sigExtra);
187 if (
188 ! roundNearEven
190 ) {
191 doIncrement =
192 (roundingMode
194 && sigExtra;
195 }
196 if ( doIncrement ) {
197 ++sig;
198 sig &= ~(
uint64_t) (! (sigExtra & 0x7FFFFFFF) & roundNearEven);
199 exp = ((sig &
UINT64_C( 0x8000000000000000 )) != 0);
200 }
201 goto packReturn;
202 }
203 if (
204 (0x7FFE < exp)
205 || ((exp == 0x7FFE) && (sig ==
UINT64_C( 0xFFFFFFFFFFFFFFFF ))
206 && doIncrement)
207 ) {
208
209
210 roundMask = 0;
214 if (
215 roundNearEven
217 || (roundingMode
219 ) {
220 exp = 0x7FFF;
221 sig =
UINT64_C( 0x8000000000000000 );
222 } else {
223 exp = 0x7FFE;
224 sig = ~roundMask;
225 }
226 goto packReturn;
227 }
228 }
229
230
231 if ( sigExtra ) {
233#ifdef SOFTFLOAT_ROUND_ODD
235 sig |= 1;
236 goto packReturn;
237 }
238#endif
239 }
240 if ( doIncrement ) {
241 ++sig;
242 if ( ! sig ) {
243 ++exp;
244 sig =
UINT64_C( 0x8000000000000000 );
245 } else {
246 sig &= ~(
uint64_t) (! (sigExtra & 0x7FFFFFFF) & roundNearEven);
247 }
248 }
249
250
251 packReturn:
254
255}
void softfloat_raiseFlags(uint_fast8_t flags)
#define packToExtF80UI64(sign, exp)
#define indexWordLo(total)
#define indexWord(total, n)
#define softfloat_shiftRightJam96M(aPtr, dist, zPtr)
uint64_t softfloat_shiftRightJam64(uint64_t a, uint_fast32_t dist)
THREAD_LOCAL uint_fast8_t softfloat_roundingMode
@ softfloat_flag_underflow
@ softfloat_flag_overflow
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags
THREAD_LOCAL uint_fast8_t softfloat_detectTininess
@ softfloat_round_near_even
@ softfloat_round_near_maxMag
@ softfloat_tininess_beforeRounding
unsigned __int64 uint64_t