MCPcopy Create free account
hub / github.com/Snapchat/Valdi / bf_set_ui

Function bf_set_ui

third-party/quickjs/src/quickjs/libbf.c:226–264  ·  view source on GitHub ↗

return 0 or BF_ST_MEM_ERROR */

Source from the content-addressed store, hash-verified

224
225/* return 0 or BF_ST_MEM_ERROR */
226int bf_set_ui(bf_t *r, uint64_t a)
227{
228 r->sign = 0;
229 if (a == 0) {
230 r->expn = BF_EXP_ZERO;
231 bf_resize(r, 0); /* cannot fail */
232 }
233#if LIMB_BITS == 32
234 else if (a <= 0xffffffff)
235#else
236 else
237#endif
238 {
239 int shift;
240 if (bf_resize(r, 1))
241 goto fail;
242 shift = clz(a);
243 r->tab[0] = a << shift;
244 r->expn = LIMB_BITS - shift;
245 }
246#if LIMB_BITS == 32
247 else {
248 uint32_t a1, a0;
249 int shift;
250 if (bf_resize(r, 2))
251 goto fail;
252 a0 = a;
253 a1 = a >> 32;
254 shift = clz(a1);
255 r->tab[0] = a0 << shift;
256 r->tab[1] = shld(a1, a0, shift);
257 r->expn = 2 * LIMB_BITS - shift;
258 }
259#endif
260 return 0;
261 fail:
262 bf_set_nan(r);
263 return BF_ST_MEM_ERROR;
264}
265
266/* return 0 or BF_ST_MEM_ERROR */
267int bf_set_si(bf_t *r, int64_t a)

Callers 15

bf_set_siFunction · 0.85
bf_tdivremuFunction · 0.85
bf_sqrtremFunction · 0.85
bf_mul_uiFunction · 0.85
bf_pow_uiFunction · 0.85
bf_pow_ui_uiFunction · 0.85
bf_integer_to_radix_recFunction · 0.85
bf_const_log2_recFunction · 0.85
chud_bsFunction · 0.85
bf_const_pi_internalFunction · 0.85
bf_add_epsilonFunction · 0.85

Calls 4

bf_resizeFunction · 0.85
clzFunction · 0.85
shldFunction · 0.85
bf_set_nanFunction · 0.85

Tested by

no test coverage detected