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

Function bf_exp

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

Source from the content-addressed store, hash-verified

4420}
4421
4422int bf_exp(bf_t *r, const bf_t *a, limb_t prec, bf_flags_t flags)
4423{
4424 bf_context_t *s = r->ctx;
4425 int ret;
4426 assert(r != a);
4427 if (a->len == 0) {
4428 if (a->expn == BF_EXP_NAN) {
4429 bf_set_nan(r);
4430 } else if (a->expn == BF_EXP_INF) {
4431 if (a->sign)
4432 bf_set_zero(r, 0);
4433 else
4434 bf_set_inf(r, 0);
4435 } else {
4436 bf_set_ui(r, 1);
4437 }
4438 return 0;
4439 }
4440
4441 ret = check_exp_underflow_overflow(s, r, a, a, prec, flags);
4442 if (ret)
4443 return ret;
4444 if (a->expn < 0 && (-a->expn) >= (prec + 2)) {
4445 /* small argument case: result = 1 + epsilon * sign(x) */
4446 bf_set_ui(r, 1);
4447 return bf_add_epsilon(r, r, -(prec + 2), a->sign, prec, flags);
4448 }
4449
4450 return bf_ziv_rounding(r, a, prec, flags, bf_exp_internal, NULL);
4451}
4452
4453static int bf_log_internal(bf_t *r, const bf_t *a, limb_t prec, void *opaque)
4454{

Callers

nothing calls this directly

Calls 7

bf_set_nanFunction · 0.85
bf_set_zeroFunction · 0.85
bf_set_infFunction · 0.85
bf_set_uiFunction · 0.85
bf_add_epsilonFunction · 0.85
bf_ziv_roundingFunction · 0.85

Tested by

no test coverage detected