Lines Matching defs:n

180  * Returns non-zero if the BcNum @a n is non-zero.
181 * @param n The number to test.
182 * @return Non-zero if @a n is non-zero, zero otherwise.
184 #define BC_NUM_NONZERO(n) ((n)->len)
187 * Returns true if the BcNum @a n is zero.
188 * @param n The number to test.
189 * @return True if @a n is zero, false otherwise.
191 #define BC_NUM_ZERO(n) (!BC_NUM_NONZERO(n))
194 * Returns true if the BcNum @a n is one with no scale.
195 * @param n The number to test.
196 * @return True if @a n equals 1 with no scale, false otherwise.
198 #define BC_NUM_ONE(n) ((n)->len == 1 && (n)->rdx == 0 && (n)->num[0] == 1)
230 * Returns the actual rdx of @a n. (It removes the negative bit.)
231 * @param n The number.
232 * @return The real rdx of @a n.
234 #define BC_NUM_RDX_VAL(n) ((n)->rdx >> 1)
237 * Returns the actual rdx of @a n, where @a n is not a pointer. (It removes the
239 * @param n The number.
240 * @return The real rdx of @a n.
242 #define BC_NUM_RDX_VAL_NP(n) ((n).rdx >> 1)
245 * Sets the rdx of @a n to @a v.
246 * @param n The number.
249 #define BC_NUM_RDX_SET(n, v) \
250 ((n)->rdx = (((v) << 1) | ((n)->rdx & (BcBigDig) 1)))
253 * Sets the rdx of @a n to @a v, where @a n is not a pointer.
254 * @param n The number.
257 #define BC_NUM_RDX_SET_NP(n, v) \
258 ((n).rdx = (((v) << 1) | ((n).rdx & (BcBigDig) 1)))
261 * Sets the rdx of @a n to @a v and the negative bit to @a neg.
262 * @param n The number.
266 #define BC_NUM_RDX_SET_NEG(n, v, neg) ((n)->rdx = (((v) << 1) | (neg)))
269 * Returns true if the rdx and scale for @a n match.
270 * @param n The number to test.
271 * @return True if the rdx and scale of @a n match, false otherwise.
273 #define BC_NUM_RDX_VALID(n) \
274 (BC_NUM_ZERO(n) || BC_NUM_RDX_VAL(n) * BC_BASE_DIGS >= (n)->scale)
277 * Returns true if the rdx and scale for @a n match, where @a n is not a
279 * @param n The number to test.
280 * @return True if the rdx and scale of @a n match, false otherwise.
282 #define BC_NUM_RDX_VALID_NP(n) \
283 ((!(n).len) || BC_NUM_RDX_VAL_NP(n) * BC_BASE_DIGS >= (n).scale)
286 * Returns true if @a n is negative, false otherwise.
287 * @param n The number to test.
288 * @return True if @a n is negative, false otherwise.
290 #define BC_NUM_NEG(n) ((n)->rdx & ((BcBigDig) 1))
293 * Returns true if @a n is negative, false otherwise, where @a n is not a
295 * @param n The number to test.
296 * @return True if @a n is negative, false otherwise.
298 #define BC_NUM_NEG_NP(n) ((n).rdx & ((BcBigDig) 1))
301 * Clears the negative bit on @a n.
302 * @param n The number.
304 #define BC_NUM_NEG_CLR(n) ((n)->rdx &= ~((BcBigDig) 1))
307 * Clears the negative bit on @a n, where @a n is not a pointer.
308 * @param n The number.
310 #define BC_NUM_NEG_CLR_NP(n) ((n).rdx &= ~((BcBigDig) 1))
313 * Sets the negative bit on @a n.
314 * @param n The number.
316 #define BC_NUM_NEG_SET(n) ((n)->rdx |= ((BcBigDig) 1))
319 * Toggles the negative bit on @a n.
320 * @param n The number.
322 #define BC_NUM_NEG_TGL(n) ((n)->rdx ^= ((BcBigDig) 1))
325 * Toggles the negative bit on @a n, where @a n is not a pointer.
326 * @param n The number.
328 #define BC_NUM_NEG_TGL_NP(n) ((n).rdx ^= ((BcBigDig) 1))
331 * Returns the rdx val for @a n if the negative bit is set to @a v.
332 * @param n The number.
334 * @return The value of the rdx of @a n if the negative bit were set to @a v.
336 #define BC_NUM_NEG_VAL(n, v) (((n)->rdx & ~((BcBigDig) 1)) | (v))
339 * Returns the rdx val for @a n if the negative bit is set to @a v, where @a n
341 * @param n The number.
343 * @return The value of the rdx of @a n if the negative bit were set to @a v.
345 #define BC_NUM_NEG_VAL_NP(n, v) (((n).rdx & ~((BcBigDig) 1)) | (v))
348 * Returns the size, in bytes, of limb array with @a n limbs.
349 * @param n The number.
350 * @return The size, in bytes, of a limb array with @a n limbs.
352 #define BC_NUM_SIZE(n) ((n) * sizeof(BcDig))
356 #define BC_NUM_PRINT(x) fprintf(stderr, "%s = %lu\n", #x, (unsigned long) (x))
401 * @param n The "digit" to print.
408 typedef void (*BcNumDigitOp)(size_t n, size_t len, bool rdx, bool bslash);
421 * Initializes @a n with @a req limbs in its array.
422 * @param n The number to initialize.
423 * @param req The number of limbs @a n must have in its limb array.
426 bc_num_init(BcNum* restrict n, size_t req);
429 * Initializes (sets up) @a n with the preallocated limb array @a num that has
432 * @param n The number to initialize.
437 bc_num_setup(BcNum* restrict n, BcDig* restrict num, size_t cap);
458 * Creates (initializes) @a n and sets its value to the equivalent of @a val.
459 * @a n must *not* be a valid or preallocated BcNum.
460 * @param n The number to initialize and set.
461 * @param val The value to set @a n's value to.
464 bc_num_createFromBigdig(BcNum* restrict n, BcBigDig val);
467 * Makes @a n valid for holding strings. @a n must *not* be allocated; this
469 * @param n The number to clear.
472 bc_num_clear(BcNum* restrict n);
482 * Returns the scale of @a n.
483 * @param n The number.
484 * @return The scale of @a n.
487 bc_num_scale(const BcNum* restrict n);
490 * Returns the length (in decimal digits) of @a n. This is complicated. First,
494 * @param n The number.
495 * @return The length of @a n.
498 bc_num_len(const BcNum* restrict n);
504 * @param n The number to convert.
508 bc_num_bigdig(const BcNum* restrict n);
513 * @param n The number to convert.
517 bc_num_bigdig2(const BcNum* restrict n);
520 * Sets @a n to the value of @a val. @a n is expected to be a valid and
522 * @param n The number to set.
526 bc_num_bigdig2num(BcNum* restrict n, BcBigDig val);
541 * Sets the seed for the PRNG @a rng from @a n.
542 * @param n The new seed for the PRNG.
546 bc_num_rng(const BcNum* restrict n, struct BcRNG* rng);
549 * Sets @a n to the value produced by the PRNG. This implements rand().
550 * @param n The number to set.
554 bc_num_createFromRNG(BcNum* restrict n, struct BcRNG* rng);
736 * Truncate @a n *by* @a places decimal places. This only extends places *after*
738 * @param n The number to truncate.
739 * @param places The number of places to truncate @a n by.
742 bc_num_truncate(BcNum* restrict n, size_t places);
745 * Extend @a n *by* @a places decimal places. This only extends places *after*
747 * @param n The number to truncate.
748 * @param places The number of places to extend @a n by.
751 bc_num_extend(BcNum* restrict n, size_t places);
754 * Shifts @a n right by @a places decimal places. This is the workhorse of the
757 * @param n The number to shift right.
758 * @param places The number of decimal places to shift @a n right by.
761 bc_num_shiftRight(BcNum* restrict n, size_t places);
785 * Sets @a n to zero with a scale of zero.
786 * @param n The number to zero.
789 bc_num_zero(BcNum* restrict n);
792 * Sets @a n to one with a scale of zero.
793 * @param n The number to set to one.
796 bc_num_one(BcNum* restrict n);
799 * An efficient function to compare @a n to zero.
800 * @param n The number to compare to zero.
804 bc_num_cmpZero(const BcNum* n);
818 * Parses a number string into the number @a n according to @a base.
819 * @param n The number to set to the parsed value.
824 bc_num_parse(BcNum* restrict n, const char* restrict val, BcBigDig base);
827 * Prints the number @a n according to @a base.
828 * @param n The number to print.
834 bc_num_print(BcNum* restrict n, BcBigDig base, bool newline);
848 * @param n The number to print as a character stream.
851 bc_num_stream(BcNum* restrict n);
859 * @param n The number to print.
864 bc_num_printDebug(const BcNum* n, const char* name, bool emptyline);
867 * Print the limbs of @a n. This is a debug-only function.
868 * @param n The number to print.
873 bc_num_printDigs(const BcDig* n, size_t len, bool emptyline);
876 * Print debug info about @a n along with its limbs.
877 * @param n The number to print.
882 bc_num_printWithDigs(const BcNum* n, const char* name, bool emptyline);
887 * @param n The number.
890 bc_num_dump(const char* varname, const BcNum* n);