Lines Matching defs:base

180  * Returns the log base 10 of @a i. I could have done this with floating-point
184 * @param i The number to return the log base 10 of.
185 * @return The log base 10 of @a i.
2343 * character according to the base.
2345 * @param base The base.
2349 bc_num_parseChar(char c, size_t base)
2363 // If the digit is greater than the base, we clamp.
2366 c = ((size_t) c) >= base ? (char) base - 1 : c;
2476 // Clamp for the base.
2514 * Parse a number in any base (besides decimal).
2517 * @param base The base to parse as.
2520 bc_num_parseBase(BcNum* restrict n, const char* restrict val, BcBigDig base)
2556 // the number by the base, then add the digit.
2560 v = bc_num_parseChar(c, base);
2563 bc_num_mulArray(n, base, &mult1);
2601 v = bc_num_parseChar(c, base);
2603 // We keep growing result2 according to the base because the more digits
2606 bc_num_mulArray(&result1, base, &result2);
2615 bc_num_mulArray(m1, base, m2);
2628 // multiplied by base, and base cannot be 0, so mult cannot be 0. And this
2932 * Takes a number with limbs with base BC_BASE_POW and converts the limb at the
2933 * given index to base @a pow, where @a pow is obase^N.
2961 // Store a value in base pow in the previous limb.
2964 // Divide by the base and accumulate the remaining value in the limb.
2968 // If the accumulator is greater than the base...
2985 // Overflow into the next limb since we are over the base.
3001 * Prepares a number for printing in a base that does not have BC_BASE_POW as a
3002 * power. This basically converts the number from having limbs of base
3005 * @param rem The remainder of BC_BASE_POW when divided by a power of the base.
3006 * @param pow The power of the base.
3051 bc_num_printNum(BcNum* restrict n, BcBigDig base, size_t len,
3068 assert(base > 1);
3079 // intp into a number of the specified base, but it does it directly,
3087 // it converts the least significant limb into one of the specified base,
3097 // the fact that limbs are not always converted into the specified base, but
3098 // into something close, basically a power of the specified base. In
3099 // Stefan's words, "You could consider BcDigs to be of base 10^BC_BASE_DIGS
3101 // obase^N <= 10^BC_BASE_DIGS. [This means that] the result is not in base
3102 // "obase", but in base "obase^N", which happens to be printable as a number
3103 // of base "obase" without consideration for neighbouring BcDigs." This fact
3112 // the limbs it passes into limbs of base obase^N rather than base
3136 // If the base is not the same as the last base used for printing, we need
3140 // base.
3141 if (base != vm->last_base)
3147 while (vm->last_pow * base <= BC_BASE_POW)
3149 vm->last_pow *= base;
3153 // Also, the remainder and base itself.
3155 vm->last_base = base;
3160 // If vm->last_rem is 0, then the base we are printing in is a divisor of
3163 // the hard case, and we have to prepare the number for the base.
3178 // Turn the limb into digits of base obase.
3184 dig = acc % base;
3185 acc /= base;
3193 assert(dig < base);
3269 bc_num_mulArray(&fracp1, base, &fracp2);
3291 bc_num_mulArray(n1, base, n2);
3315 * Prints a number in the specified base, or rather, figures out which function
3316 * to call to print the number in the specified base and calls it.
3318 * @param base The base to print in.
3322 bc_num_printBase(BcNum* restrict n, BcBigDig base, bool newline)
3334 if (base <= BC_NUM_MAX_POSIX_IBASE)
3341 assert(base <= BC_BASE_POW);
3342 width = bc_num_log10(base - 1);
3347 bc_num_printNum(n, base, width, print, newline);
3493 bc_num_parse(BcNum* restrict n, const char* restrict val, BcBigDig base)
3501 assert(n != NULL && val != NULL && base);
3502 assert(base >= BC_NUM_MIN_BASE && base <= vm->maxes[BC_PROG_GLOBALS_IBASE]);
3505 // A one character number is *always* parsed as though the base was the
3512 else if (base == BC_BASE) bc_num_parseDecimal(n, val);
3513 else bc_num_parseBase(n, val, base);
3519 bc_num_print(BcNum* restrict n, BcBigDig base, bool newline)
3522 assert(BC_ENABLE_EXTRA_MATH || base >= BC_NUM_MIN_BASE);
3538 if (BC_Z && BC_NUM_RDX_VAL(n) == n->len && base != 0 && base != 1)
3546 else if (base == BC_BASE) bc_num_printDecimal(n, newline);
3548 else if (base == 0 || base == 1)
3550 bc_num_printExponent(n, base != 0, newline);
3553 else bc_num_printBase(n, base, newline);
4319 BcNum base, exp, two, temp, atemp, btemp, ctemp;
4348 bc_num_init(&base, ctemp.len);
4362 bc_num_rem(&atemp, &ctemp, &base, 0);
4374 assert(BC_NUM_RDX_VALID_NP(base));
4376 bc_num_mul(d, &base, &temp, 0);
4382 assert(BC_NUM_RDX_VALID_NP(base));
4384 bc_num_mul(&base, &base, &temp, 0);
4387 bc_num_rem(&temp, &ctemp, &base, 0);
4394 bc_num_free(&base);