Lines Matching refs:scale
55 bc_num_m(BcNum* a, BcNum* b, BcNum* restrict c, size_t scale);
134 bc_num_setToZero(BcNum* restrict n, size_t scale) in bc_num_setToZero() argument
137 n->scale = scale; in bc_num_setToZero()
227 bc_num_leastSigPow(size_t scale) in bc_num_leastSigPow() argument
231 digs = scale % BC_BASE_DIGS; in bc_num_leastSigPow()
587 places_rdx = nrdx ? nrdx - BC_NUM_RDX(n->scale - places) : 0; in bc_num_truncate()
590 assert(places <= n->scale && (BC_NUM_ZERO(n) || places_rdx <= n->len)); in bc_num_truncate()
592 n->scale -= places; in bc_num_truncate()
602 pow = bc_num_leastSigPow(n->scale); in bc_num_truncate()
628 n->scale += places; in bc_num_extend()
635 places_rdx = BC_NUM_RDX(places + n->scale) - nrdx; in bc_num_extend()
650 n->scale += places; in bc_num_extend()
653 assert(BC_NUM_RDX_VAL(n) == BC_NUM_RDX(n->scale)); in bc_num_extend()
660 bc_num_retireMul(BcNum* restrict n, size_t scale, bool neg1, bool neg2) in bc_num_retireMul() argument
663 if (n->scale < scale) bc_num_extend(n, scale - n->scale); in bc_num_retireMul()
664 else bc_num_truncate(n, n->scale - scale); in bc_num_retireMul()
693 a->scale = b->scale = 0; in bc_num_split()
731 r->scale = 0; in bc_num_shiftRdx()
825 if (places > n->scale) in bc_num_shiftLeft()
827 size_t size = bc_vm_growSize(BC_NUM_RDX(places - n->scale), n->len); in bc_num_shiftLeft()
834 if (n->scale >= places) n->scale -= places; in bc_num_shiftLeft()
835 else n->scale = 0; in bc_num_shiftLeft()
854 if (n->scale) in bc_num_shiftLeft()
861 size_t mod = n->scale % BC_BASE_DIGS, revdig; in bc_num_shiftLeft()
889 if (places > n->scale) in bc_num_shiftLeft()
891 n->scale = 0; in bc_num_shiftLeft()
896 n->scale -= places; in bc_num_shiftLeft()
897 BC_NUM_RDX_SET(n, BC_NUM_RDX(n->scale)); in bc_num_shiftLeft()
910 size_t places_rdx, scale, scale_mod, int_len, expand; in bc_num_shiftRight() local
918 n->scale += places; in bc_num_shiftRight()
919 bc_num_expand(n, BC_NUM_RDX(n->scale)); in bc_num_shiftRight()
927 scale = n->scale; in bc_num_shiftRight()
930 scale_mod = scale % BC_BASE_DIGS; in bc_num_shiftRight()
961 n->scale = 0; in bc_num_shiftRight()
967 n->scale = scale + places; in bc_num_shiftRight()
968 BC_NUM_RDX_SET(n, BC_NUM_RDX(n->scale)); in bc_num_shiftRight()
973 assert(BC_NUM_RDX_VAL(n) == BC_NUM_RDX(n->scale)); in bc_num_shiftRight()
1230 c->scale = BC_MAX(a->scale, b->scale); in bc_num_as()
1481 bc_num_m(BcNum* a, BcNum* b, BcNum* restrict c, size_t scale) in bc_num_m() argument
1501 ascale = a->scale; in bc_num_m()
1502 bscale = b->scale; in bc_num_m()
1505 scale1 = BC_MAX(scale, ascale); in bc_num_m()
1693 size_t scale) in bc_num_d_long() argument
1729 c->scale = a->scale; in bc_num_d_long()
1792 assert(c->scale >= scale); in bc_num_d_long()
1793 rdx = BC_NUM_RDX_VAL(c) - BC_NUM_RDX(scale); in bc_num_d_long()
1878 bc_num_d(BcNum* a, BcNum* b, BcNum* restrict c, size_t scale) in bc_num_d() argument
1890 bc_num_setToZero(c, scale); in bc_num_d()
1897 bc_num_retireMul(c, scale, BC_NUM_NEG(a), BC_NUM_NEG(b)); in bc_num_d()
1902 if (!BC_NUM_RDX_VAL(a) && !BC_NUM_RDX_VAL(b) && b->len == 1 && !scale) in bc_num_d()
1906 bc_num_retireMul(c, scale, BC_NUM_NEG(a), BC_NUM_NEG(b)); in bc_num_d()
1910 len = bc_num_divReq(a, b, scale); in bc_num_d()
1936 cpa.scale = cpardx * BC_BASE_DIGS; in bc_num_d()
1939 bc_num_extend(&cpa, b->scale); in bc_num_d()
1940 cpardx = BC_NUM_RDX_VAL_NP(cpa) - BC_NUM_RDX(b->scale); in bc_num_d()
1942 cpa.scale = cpardx * BC_BASE_DIGS; in bc_num_d()
1945 if (scale > cpa.scale) in bc_num_d()
1947 bc_num_extend(&cpa, scale); in bc_num_d()
1949 cpa.scale = cpardx * BC_BASE_DIGS; in bc_num_d()
1968 cpb.scale = 0; in bc_num_d()
1971 bc_num_d_long(&cpa, &cpb, c, scale); in bc_num_d()
1973 bc_num_retireMul(c, scale, BC_NUM_NEG(a), BC_NUM_NEG(b)); in bc_num_d()
1995 bc_num_r(BcNum* a, BcNum* b, BcNum* restrict c, BcNum* restrict d, size_t scale, in bc_num_r() argument
2025 bc_num_d(a, b, c, scale); in bc_num_r()
2028 if (scale) realscale = ts + 1; in bc_num_r()
2029 else realscale = scale; in bc_num_r()
2039 if (ts > d->scale && BC_NUM_NONZERO(d)) bc_num_extend(d, ts - d->scale); in bc_num_r()
2060 bc_num_rem(BcNum* a, BcNum* b, BcNum* restrict c, size_t scale) in bc_num_rem() argument
2068 ts = bc_vm_growSize(scale, b->scale); in bc_num_rem()
2069 ts = BC_MAX(ts, a->scale); in bc_num_rem()
2080 bc_num_r(a, b, &c1, c, scale, ts); in bc_num_rem()
2096 bc_num_p(BcNum* a, BcNum* b, BcNum* restrict c, size_t scale) in bc_num_p() argument
2128 bc_num_setToZero(c, scale); in bc_num_p()
2135 else bc_num_inv(a, c, scale); in bc_num_p()
2156 size_t max = BC_MAX(scale, a->scale), scalepow; in bc_num_p()
2157 scalepow = bc_num_mulOverflow(a->scale, exp); in bc_num_p()
2160 else realscale = scale; in bc_num_p()
2164 for (powrdx = a->scale; !(exp & 1); exp >>= 1) in bc_num_p()
2199 if (c->scale > realscale) bc_num_truncate(c, c->scale - realscale); in bc_num_p()
2218 bc_num_place(BcNum* a, BcNum* b, BcNum* restrict c, size_t scale) in bc_num_place() argument
2222 BC_UNUSED(scale); in bc_num_place()
2227 if (val < c->scale) bc_num_truncate(c, c->scale - val); in bc_num_place()
2228 else if (val > c->scale) bc_num_extend(c, val - c->scale); in bc_num_place()
2235 bc_num_left(BcNum* a, BcNum* b, BcNum* restrict c, size_t scale) in bc_num_left() argument
2239 BC_UNUSED(scale); in bc_num_left()
2250 bc_num_right(BcNum* a, BcNum* b, BcNum* restrict c, size_t scale) in bc_num_right() argument
2254 BC_UNUSED(scale); in bc_num_right()
2283 bc_num_binary(BcNum* a, BcNum* b, BcNum* c, size_t scale, BcNumBinOp op, in bc_num_binary() argument
2332 op(ptr_a, ptr_b, c, scale); in bc_num_binary()
2475 n->scale = (size_t) (rdx * in bc_num_parseDecimal()
2479 BC_NUM_RDX_SET(n, BC_NUM_RDX(n->scale)); in bc_num_parseDecimal()
2485 mod = n->scale % BC_BASE_DIGS; in bc_num_parseDecimal()
2694 if (n->scale < digs) bc_num_extend(n, digs - n->scale); in bc_num_parseBase()
2847 temp = n->scale % BC_BASE_DIGS; in bc_num_printDecimal()
3173 bc_num_truncate(&intp, intp.scale); in bc_num_printNum()
3275 !newline || (n->scale != 0 || i < stack.len - 1)); in bc_num_printNum()
3279 if (!n->scale) goto err; in bc_num_printNum()
3303 fracp2.scale = n->scale; in bc_num_printNum()
3304 BC_NUM_RDX_SET_NP(fracp2, BC_NUM_RDX(fracp2.scale)); in bc_num_printNum()
3307 while ((idigits = bc_num_intDigits(n1)) <= n->scale) in bc_num_printNum()
3330 print(dig, len, radix, !newline || idigits != n->scale); in bc_num_printNum()
3471 d->scale = s->scale; in bc_num_copy()
3495 return n->scale; in bc_num_scale()
3504 if (BC_NUM_ZERO(n)) return n->scale ? n->scale : 1; in bc_num_len()
3513 size_t zero, scale; in bc_num_len() local
3519 scale = n->scale % BC_BASE_DIGS; in bc_num_len()
3520 scale = scale ? scale : BC_BASE_DIGS; in bc_num_len()
3526 len = len * BC_BASE_DIGS - zero - (BC_BASE_DIGS - scale); in bc_num_len()
3529 else len = bc_num_intDigits(n) + n->scale; in bc_num_len()
3733 frac.scale = n->scale; in bc_num_rng()
3741 bc_num_truncate(&temp, temp.scale); in bc_num_rng()
3977 bc_num_addReq(const BcNum* a, const BcNum* b, size_t scale) in bc_num_addReq() argument
3984 BC_UNUSED(scale); in bc_num_addReq()
4001 bc_num_mulReq(const BcNum* a, const BcNum* b, size_t scale) in bc_num_mulReq() argument
4009 max = BC_NUM_RDX(scale); in bc_num_mulReq()
4018 bc_num_divReq(const BcNum* a, const BcNum* b, size_t scale) in bc_num_divReq() argument
4026 max = BC_NUM_RDX(scale); in bc_num_divReq()
4035 bc_num_powReq(const BcNum* a, const BcNum* b, size_t scale) in bc_num_powReq() argument
4037 BC_UNUSED(scale); in bc_num_powReq()
4043 bc_num_placesReq(const BcNum* a, const BcNum* b, size_t scale) in bc_num_placesReq() argument
4045 BC_UNUSED(scale); in bc_num_placesReq()
4051 bc_num_add(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_add() argument
4055 bc_num_binary(a, b, c, false, bc_num_as, bc_num_addReq(a, b, scale)); in bc_num_add()
4059 bc_num_sub(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_sub() argument
4063 bc_num_binary(a, b, c, true, bc_num_as, bc_num_addReq(a, b, scale)); in bc_num_sub()
4067 bc_num_mul(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_mul() argument
4071 bc_num_binary(a, b, c, scale, bc_num_m, bc_num_mulReq(a, b, scale)); in bc_num_mul()
4075 bc_num_div(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_div() argument
4079 bc_num_binary(a, b, c, scale, bc_num_d, bc_num_divReq(a, b, scale)); in bc_num_div()
4083 bc_num_mod(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_mod() argument
4087 bc_num_binary(a, b, c, scale, bc_num_rem, bc_num_divReq(a, b, scale)); in bc_num_mod()
4091 bc_num_pow(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_pow() argument
4095 bc_num_binary(a, b, c, scale, bc_num_p, bc_num_powReq(a, b, scale)); in bc_num_pow()
4100 bc_num_places(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_places() argument
4104 bc_num_binary(a, b, c, scale, bc_num_place, bc_num_placesReq(a, b, scale)); in bc_num_places()
4108 bc_num_lshift(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_lshift() argument
4112 bc_num_binary(a, b, c, scale, bc_num_left, bc_num_placesReq(a, b, scale)); in bc_num_lshift()
4116 bc_num_rshift(BcNum* a, BcNum* b, BcNum* c, size_t scale) in bc_num_rshift() argument
4120 bc_num_binary(a, b, c, scale, bc_num_right, bc_num_placesReq(a, b, scale)); in bc_num_rshift()
4125 bc_num_sqrt(BcNum* restrict a, BcNum* restrict b, size_t scale) in bc_num_sqrt() argument
4145 if (a->scale > scale) realscale = a->scale; in bc_num_sqrt()
4146 else realscale = scale; in bc_num_sqrt()
4234 x0->scale = x0->rdx = 0; in bc_num_sqrt()
4262 if (b->scale > realscale) bc_num_truncate(b, b->scale - realscale); in bc_num_sqrt()
4279 bc_num_divmod(BcNum* a, BcNum* b, BcNum* c, BcNum* d, size_t scale) in bc_num_divmod() argument
4294 ts = BC_MAX(scale + b->scale, a->scale); in bc_num_divmod()
4325 b->len == 1 && !scale) in bc_num_divmod()
4337 else bc_num_r(ptr_a, b, c, d, scale, ts); in bc_num_divmod()
4475 BC_NUM_RDX_VAL(n), n->scale); in bc_num_printWithDigs()
4482 ulong i, scale = n->scale; in bc_num_dump() local
4494 if (scale / BC_BASE_DIGS != BC_NUM_RDX_VAL(n) - i - 1) in bc_num_dump()
4500 int mod = scale % BC_BASE_DIGS; in bc_num_dump()
4515 bc_file_printf(&vm->ferr, "(%zu | %zu.%zu / %zu) %lu\n", n->scale, n->len, in bc_num_dump()