MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / xsum_small_add_inf_nan

Function xsum_small_add_inf_nan

xs/sources/xsum.c:139–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 matter. */
138
139static NOINLINE void xsum_small_add_inf_nan
140 (xsum_small_accumulator *restrict sacc, xsum_int ivalue)
141{
142 xsum_int mantissa;
143 double fltv;
144
145 mantissa = ivalue & XSUM_MANTISSA_MASK;
146
147 if (mantissa == 0) /* Inf */
148 { if (sacc->Inf == 0)
149 { /* no previous Inf */
150 sacc->Inf = ivalue;
151 }
152 else if (sacc->Inf != ivalue)
153 { /* previous Inf was opposite sign */
154 COPY64 (fltv, ivalue);
155 fltv = fltv - fltv; /* result will be a NaN */
156 COPY64 (sacc->Inf, fltv);
157 }
158 }
159 else /* NaN */
160 { /* Choose the NaN with the bigger payload and clear its sign. Using <=
161 ensures that we will choose the first NaN over the previous zero. */
162 if ((sacc->NaN & XSUM_MANTISSA_MASK) <= mantissa)
163 { sacc->NaN = ivalue & ~XSUM_SIGN_MASK;
164 }
165 }
166}
167
168
169/* PROPAGATE CARRIES TO NEXT CHUNK IN A SMALL ACCUMULATOR. Needs to

Callers 4

xsum_carry_propagateFunction · 0.85
xsum_add1_no_carryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected