Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
bignum.c File Reference
#include "internal.h"
#include "ruby/thread.h"
#include "ruby/util.h"
#include <math.h>
#include <float.h>
#include <ctype.h>
#include "ruby_assert.h"
Include dependency graph for bignum.c:

Go to the source code of this file.

Data Structures

struct  big_div_struct
 
struct  big2str_struct
 

Macros

#define RB_BIGNUM_TYPE_P(x)   RB_TYPE_P((x), T_BIGNUM)
 
#define SIZEOF_BDIGIT_DBL   SIZEOF_LONG_LONG
 
#define HOST_BIGENDIAN_P   0
 
#define ALIGNOF(type)   ((int)offsetof(struct { char f1; type f2; }, f2))
 
#define LSHIFTABLE(d, n)   ((n) < sizeof(d) * CHAR_BIT)
 
#define LSHIFTX(d, n)   (!LSHIFTABLE(d, n) ? 0 : ((d) << (!LSHIFTABLE(d, n) ? 0 : (n))))
 
#define CLEAR_LOWBITS(d, numbits)   ((d) & LSHIFTX(~((d)*0), (numbits)))
 
#define FILL_LOWBITS(d, numbits)   ((d) | (LSHIFTX(((d)*0+1), (numbits))-1))
 
#define POW2_P(x)   (((x)&((x)-1))==0)
 
#define BDIGITS(x)   (BIGNUM_DIGITS(x))
 
#define BITSPERDIG   (SIZEOF_BDIGIT*CHAR_BIT)
 
#define BIGRAD   ((BDIGIT_DBL)1 << BITSPERDIG)
 
#define BIGRAD_HALF   ((BDIGIT)(BIGRAD >> 1))
 
#define BDIGIT_MSB(d)   (((d) & BIGRAD_HALF) != 0)
 
#define BIGUP(x)   LSHIFTX(((x) + (BDIGIT_DBL)0), BITSPERDIG)
 
#define BIGDN(x)   RSHIFT((x),BITSPERDIG)
 
#define BIGLO(x)   ((BDIGIT)((x) & BDIGMAX))
 
#define BDIGMAX   ((BDIGIT)(BIGRAD-1))
 
#define BDIGIT_DBL_MAX   (~(BDIGIT_DBL)0)
 
#define BIGZEROP(x)
 
#define BIGSIZE(x)
 
#define BIGDIVREM_EXTRA_WORDS   1
 
#define bdigit_roomof(n)   roomof(n, SIZEOF_BDIGIT)
 
#define BARY_ARGS(ary)   ary, numberof(ary)
 
#define BARY_ADD(z, x, y)   bary_add(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))
 
#define BARY_SUB(z, x, y)   bary_sub(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))
 
#define BARY_SHORT_MUL(z, x, y)   bary_short_mul(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))
 
#define BARY_DIVMOD(q, r, x, y)   bary_divmod(BARY_ARGS(q), BARY_ARGS(r), BARY_ARGS(x), BARY_ARGS(y))
 
#define BARY_ZERO_P(x)   bary_zero_p(BARY_ARGS(x))
 
#define BIGNUM_SET_NEGATIVE_SIGN(b)   BIGNUM_SET_SIGN(b, 0)
 
#define BIGNUM_SET_POSITIVE_SIGN(b)   BIGNUM_SET_SIGN(b, 1)
 
#define bignew(len, sign)   bignew_1(rb_cInteger,(len),(sign))
 
#define BDIGITS_ZERO(ptr, n)
 
#define BARY_TRUNC(ds, n)
 
#define KARATSUBA_BALANCED(xn, yn)   ((yn)/2 < (xn))
 
#define TOOM3_BALANCED(xn, yn)   (((yn)+2)/3 * 2 < (xn))
 
#define GMP_MUL_DIGITS   20
 
#define KARATSUBA_MUL_DIGITS   70
 
#define TOOM3_MUL_DIGITS   150
 
#define GMP_DIV_DIGITS   20
 
#define GMP_BIG2STR_DIGITS   20
 
#define GMP_STR2BIG_DIGITS   20
 
#define U16(a)   ((uint16_t)(a))
 
#define U32(a)   ((uint32_t)(a))
 
#define INTEGER_PACK_WORDORDER_MASK
 
#define INTEGER_PACK_BYTEORDER_MASK
 
#define FILL_DD   integer_pack_fill_dd(&dp, &de, &dd, &numbits_in_dd)
 
#define TAKE_LOWBITS(n)   integer_pack_take_lowbits(n, &dd, &numbits_in_dd)
 
#define PUSH_BITS(data, numbits)   integer_unpack_push_bits(data, numbits, &dd, &numbits_in_dd, &dp)
 
#define BIGNUM_DEBUG   0
 
#define ON_DEBUG(x)
 
#define BIGNUM_SET_LEN(b, l)
 
#define conv_digit(c)   (ruby_digit36_to_number_table[(unsigned char)(c)])
 
#define ADV(n)
 
#define ASSERT_LEN()
 
#define MAX_BASE36_POWER_TABLE_ENTRIES   (SIZEOF_SIZE_T * CHAR_BIT + 1)
 
#define DBL_BIGDIG   ((DBL_MANT_DIG + BITSPERDIG) / BITSPERDIG)
 

Typedefs

typedef void() mulfunc_t(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn)
 

Enumerations

enum  big_op_t { big_op_gt, big_op_ge, big_op_lt, big_op_le }
 

Functions

 STATIC_ASSERT (sizeof_bdigit_dbl, sizeof(BDIGIT_DBL)==SIZEOF_BDIGIT_DBL)
 
 STATIC_ASSERT (sizeof_bdigit_dbl_signed, sizeof(BDIGIT_DBL_SIGNED)==SIZEOF_BDIGIT_DBL)
 
 STATIC_ASSERT (sizeof_bdigit, SIZEOF_BDIGIT<=sizeof(BDIGIT))
 
 STATIC_ASSERT (sizeof_bdigit_and_dbl, SIZEOF_BDIGIT *2<=SIZEOF_BDIGIT_DBL)
 
 STATIC_ASSERT (bdigit_signedness, 0<(BDIGIT) -1)
 
 STATIC_ASSERT (bdigit_dbl_signedness, 0<(BDIGIT_DBL) -1)
 
 STATIC_ASSERT (bdigit_dbl_signed_signedness, 0 >(BDIGIT_DBL_SIGNED) -1)
 
 STATIC_ASSERT (rbignum_embed_len_max, BIGNUM_EMBED_LEN_MAX<=(BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT))
 
 STATIC_ASSERT (sizeof_long_and_sizeof_bdigit, SIZEOF_BDIGIT % SIZEOF_LONG==0)
 
static BDIGIT bigdivrem_single (BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT y)
 
static void bary_divmod (BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
static VALUE bigmul0 (VALUE x, VALUE y)
 
static void bary_mul_toom3 (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn)
 
static VALUE bignew_1 (VALUE klass, size_t len, int sign)
 
static VALUE bigtrunc (VALUE x)
 
static VALUE bigsq (VALUE x)
 
static void bigdivmod (VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
 
static VALUE power_cache_get_power (int base, int power_level, size_t *numdigits_ret)
 
static int nlz (BDIGIT x)
 
static BDIGIT_DBL maxpow_in_bdigit_dbl (int base, int *exp_ret)
 
static BDIGIT_DBL bary2bdigitdbl (const BDIGIT *ds, size_t n)
 
static void bdigitdbl2bary (BDIGIT *ds, size_t n, BDIGIT_DBL num)
 
static int bary_cmp (const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
static BDIGIT bary_small_lshift (BDIGIT *zds, const BDIGIT *xds, size_t n, int shift)
 
static void bary_small_rshift (BDIGIT *zds, const BDIGIT *xds, size_t n, int shift, BDIGIT higher_bdigit)
 
static int bary_zero_p (BDIGIT *xds, size_t xn)
 
static void bary_neg (BDIGIT *ds, size_t n)
 
static int bary_2comp (BDIGIT *ds, size_t n)
 
static void bary_swap (BDIGIT *ds, size_t num_bdigits)
 
static void validate_integer_pack_format (size_t numwords, size_t wordsize, size_t nails, int flags, int supported_flags)
 
static void integer_pack_loop_setup (size_t numwords, size_t wordsize, size_t nails, int flags, size_t *word_num_fullbytes_ret, int *word_num_partialbits_ret, size_t *word_start_ret, ssize_t *word_step_ret, size_t *word_last_ret, size_t *byte_start_ret, int *byte_step_ret)
 
static void integer_pack_fill_dd (BDIGIT **dpp, BDIGIT **dep, BDIGIT_DBL *ddp, int *numbits_in_dd_p)
 
static BDIGIT_DBL integer_pack_take_lowbits (int n, BDIGIT_DBL *ddp, int *numbits_in_dd_p)
 
static int bytes_2comp (unsigned char *buf, size_t len)
 
static int bary_pack (int sign, BDIGIT *ds, size_t num_bdigits, void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
 
static size_t integer_unpack_num_bdigits_small (size_t numwords, size_t wordsize, size_t nails, int *nlp_bits_ret)
 
static size_t integer_unpack_num_bdigits_generic (size_t numwords, size_t wordsize, size_t nails, int *nlp_bits_ret)
 
static size_t integer_unpack_num_bdigits (size_t numwords, size_t wordsize, size_t nails, int *nlp_bits_ret)
 
static void integer_unpack_push_bits (int data, int numbits, BDIGIT_DBL *ddp, int *numbits_in_dd_p, BDIGIT **dpp)
 
static int integer_unpack_single_bdigit (BDIGIT u, size_t size, int flags, BDIGIT *dp)
 
static int bary_unpack_internal (BDIGIT *bdigits, size_t num_bdigits, const void *words, size_t numwords, size_t wordsize, size_t nails, int flags, int nlp_bits)
 
static void bary_unpack (BDIGIT *bdigits, size_t num_bdigits, const void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
 
static int bary_subb (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, int borrow)
 
static int bary_sub (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
static int bary_sub_one (BDIGIT *zds, size_t zn)
 
static int bary_addc (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, int carry)
 
static int bary_add (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
static int bary_add_one (BDIGIT *ds, size_t n)
 
static void bary_mul_single (BDIGIT *zds, size_t zn, BDIGIT x, BDIGIT y)
 
static int bary_muladd_1xN (BDIGIT *zds, size_t zn, BDIGIT x, const BDIGIT *yds, size_t yn)
 
static BDIGIT_DBL_SIGNED bigdivrem_mulsub (BDIGIT *zds, size_t zn, BDIGIT x, const BDIGIT *yds, size_t yn)
 
static int bary_mulsub_1xN (BDIGIT *zds, size_t zn, BDIGIT x, const BDIGIT *yds, size_t yn)
 
static void bary_mul_normal (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
VALUE rb_big_mul_normal (VALUE x, VALUE y)
 
static void bary_sq_fast (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn)
 
VALUE rb_big_sq_fast (VALUE x)
 
static void bary_mul_balance_with_mulfunc (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn, mulfunc_t *mulfunc)
 
VALUE rb_big_mul_balance (VALUE x, VALUE y)
 
static void bary_mul_karatsuba (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn)
 
VALUE rb_big_mul_karatsuba (VALUE x, VALUE y)
 
VALUE rb_big_mul_toom3 (VALUE x, VALUE y)
 
static void bary_short_mul (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
static int bary_sparse_p (const BDIGIT *ds, size_t n)
 
static int bary_mul_precheck (BDIGIT **zdsp, size_t *znp, const BDIGIT **xdsp, size_t *xnp, const BDIGIT **ydsp, size_t *ynp)
 
static void bary_mul_karatsuba_branch (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn)
 
static void bary_mul_karatsuba_start (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn)
 
static void bary_mul_toom3_branch (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn)
 
static void bary_mul_toom3_start (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn)
 
static void bary_mul (BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
static void * bigdivrem1 (void *ptr)
 
static void rb_big_stop (void *ptr)
 
static BDIGIT bigdivrem_single1 (BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT x_higher_bdigit, BDIGIT y)
 
static void bigdivrem_restoring (BDIGIT *zds, size_t zn, BDIGIT *yds, size_t yn)
 
static void bary_divmod_normal (BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
VALUE rb_big_divrem_normal (VALUE x, VALUE y)
 
static void bary_divmod_branch (BDIGIT *qds, size_t qn, BDIGIT *rds, size_t rn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn)
 
static int bigzero_p (VALUE x)
 
int rb_bigzero_p (VALUE x)
 
int rb_cmpint (VALUE val, VALUE a, VALUE b)
 
static void rb_big_realloc (VALUE big, size_t len)
 
void rb_big_resize (VALUE big, size_t len)
 
VALUE rb_big_new (size_t len, int sign)
 
VALUE rb_big_clone (VALUE x)
 
static void big_extend_carry (VALUE x)
 
static void get2comp (VALUE x)
 
void rb_big_2comp (VALUE x)
 
static BDIGIT abs2twocomp (VALUE *xp, long *n_ret)
 
static void twocomp2abs_bang (VALUE x, int hibits)
 
static VALUE bigfixize (VALUE x)
 
static VALUE bignorm (VALUE x)
 
VALUE rb_big_norm (VALUE x)
 
VALUE rb_uint2big (VALUE n)
 
VALUE rb_int2big (SIGNED_VALUE n)
 
VALUE rb_uint2inum (VALUE n)
 
VALUE rb_int2inum (SIGNED_VALUE n)
 
void rb_big_pack (VALUE val, unsigned long *buf, long num_longs)
 
VALUE rb_big_unpack (unsigned long *buf, long num_longs)
 
size_t rb_absint_size (VALUE val, int *nlz_bits_ret)
 
static size_t absint_numwords_small (size_t numbytes, int nlz_bits_in_msbyte, size_t word_numbits, size_t *nlz_bits_ret)
 
static size_t absint_numwords_generic (size_t numbytes, int nlz_bits_in_msbyte, size_t word_numbits, size_t *nlz_bits_ret)
 
size_t rb_absint_numwords (VALUE val, size_t word_numbits, size_t *nlz_bits_ret)
 
int rb_absint_singlebit_p (VALUE val)
 
int rb_integer_pack (VALUE val, void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
 
VALUE rb_integer_unpack (const void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
 
 NORETURN (static inline void invalid_radix(int base))
 
 NORETURN (static inline void invalid_integer(VALUE s))
 
static int valid_radix_p (int base)
 
static void invalid_radix (int base)
 
static void invalid_integer (VALUE s)
 
static int str2big_scan_digits (const char *s, const char *str, int base, int badcheck, size_t *num_digits_p, ssize_t *len_p)
 
static VALUE str2big_poweroftwo (int sign, const char *digits_start, const char *digits_end, size_t num_digits, int bits_per_digit)
 
static VALUE str2big_normal (int sign, const char *digits_start, const char *digits_end, size_t num_bdigits, int base)
 
static VALUE str2big_karatsuba (int sign, const char *digits_start, const char *digits_end, size_t num_digits, size_t num_bdigits, int digits_per_bdigits_dbl, int base)
 
VALUE rb_cstr_to_inum (const char *str, int base, int badcheck)
 
VALUE rb_cstr_parse_inum (const char *str, ssize_t len, char **endp, int base)
 
VALUE rb_str_to_inum (VALUE str, int base, int badcheck)
 
VALUE rb_str2big_poweroftwo (VALUE arg, int base, int badcheck)
 
VALUE rb_str2big_normal (VALUE arg, int base, int badcheck)
 
VALUE rb_str2big_karatsuba (VALUE arg, int base, int badcheck)
 
VALUE rb_cstr2inum (const char *str, int base)
 
VALUE rb_str2inum (VALUE str, int base)
 
static VALUE big_shift3 (VALUE x, int lshift_p, size_t shift_numdigits, int shift_numbits)
 
static VALUE big_shift2 (VALUE x, int lshift_p, VALUE y)
 
static VALUE big_lshift (VALUE x, unsigned long shift)
 
static VALUE big_rshift (VALUE x, unsigned long shift)
 
static void power_cache_init (void)
 
static void big2str_alloc (struct big2str_struct *b2s, size_t len)
 
static void big2str_2bdigits (struct big2str_struct *b2s, BDIGIT *xds, size_t xn, size_t taillen)
 
static void big2str_karatsuba (struct big2str_struct *b2s, BDIGIT *xds, size_t xn, size_t wn, int power_level, size_t taillen)
 
static VALUE big2str_base_poweroftwo (VALUE x, int base)
 
VALUE rb_big2str_poweroftwo (VALUE x, int base)
 
static VALUE big2str_generic (VALUE x, int base)
 
VALUE rb_big2str_generic (VALUE x, int base)
 
static VALUE rb_big2str1 (VALUE x, int base)
 
VALUE rb_big2str (VALUE x, int base)
 
static unsigned long big2ulong (VALUE x, const char *type)
 
unsigned long rb_big2ulong (VALUE x)
 
long rb_big2long (VALUE x)
 
static VALUE dbl2big (double d)
 
VALUE rb_dbl2big (double d)
 
static double big2dbl (VALUE x)
 
double rb_big2dbl (VALUE x)
 
VALUE rb_integer_float_cmp (VALUE x, VALUE y)
 
VALUE rb_integer_float_eq (VALUE x, VALUE y)
 
VALUE rb_big_cmp (VALUE x, VALUE y)
 
static VALUE big_op (VALUE x, VALUE y, enum big_op_t op)
 
VALUE rb_big_gt (VALUE x, VALUE y)
 
VALUE rb_big_ge (VALUE x, VALUE y)
 
VALUE rb_big_lt (VALUE x, VALUE y)
 
VALUE rb_big_le (VALUE x, VALUE y)
 
VALUE rb_big_eq (VALUE x, VALUE y)
 
VALUE rb_big_eql (VALUE x, VALUE y)
 
VALUE rb_big_uminus (VALUE x)
 
VALUE rb_big_comp (VALUE x)
 
static VALUE bigsub (VALUE x, VALUE y)
 
static VALUE bigadd_int (VALUE x, long y)
 
static VALUE bigsub_int (VALUE x, long y0)
 
static VALUE bigadd (VALUE x, VALUE y, int sign)
 
VALUE rb_big_plus (VALUE x, VALUE y)
 
VALUE rb_big_minus (VALUE x, VALUE y)
 
VALUE rb_big_mul (VALUE x, VALUE y)
 
static VALUE bigdivrem (VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
 
static VALUE rb_big_divide (VALUE x, VALUE y, ID op)
 
VALUE rb_big_div (VALUE x, VALUE y)
 
VALUE rb_big_idiv (VALUE x, VALUE y)
 
VALUE rb_big_modulo (VALUE x, VALUE y)
 
VALUE rb_big_remainder (VALUE x, VALUE y)
 
VALUE rb_big_divmod (VALUE x, VALUE y)
 
static VALUE big_shift (VALUE x, long n)
 
static double big_fdiv (VALUE x, VALUE y, long ey)
 
static double big_fdiv_int (VALUE x, VALUE y)
 
static double big_fdiv_float (VALUE x, VALUE y)
 
double rb_big_fdiv_double (VALUE x, VALUE y)
 
VALUE rb_big_fdiv (VALUE x, VALUE y)
 
VALUE rb_big_pow (VALUE x, VALUE y)
 
static VALUE bigand_int (VALUE x, long xn, BDIGIT hibitsx, long y)
 
VALUE rb_big_and (VALUE x, VALUE y)
 
static VALUE bigor_int (VALUE x, long xn, BDIGIT hibitsx, long y)
 
VALUE rb_big_or (VALUE x, VALUE y)
 
static VALUE bigxor_int (VALUE x, long xn, BDIGIT hibitsx, long y)
 
VALUE rb_big_xor (VALUE x, VALUE y)
 
VALUE rb_big_lshift (VALUE x, VALUE y)
 
VALUE rb_big_rshift (VALUE x, VALUE y)
 
VALUE rb_big_aref (VALUE x, VALUE y)
 
VALUE rb_big_hash (VALUE x)
 
static VALUE rb_int_coerce (VALUE x, VALUE y)
 
VALUE rb_big_abs (VALUE x)
 
int rb_big_sign (VALUE x)
 
size_t rb_big_size (VALUE big)
 
VALUE rb_big_size_m (VALUE big)
 
VALUE rb_big_bit_length (VALUE big)
 
VALUE rb_big_odd_p (VALUE num)
 
VALUE rb_big_even_p (VALUE num)
 
void Init_Bignum (void)
 

Variables

const char ruby_digitmap [] = "0123456789abcdefghijklmnopqrstuvwxyz"
 
static mulfunc_t bary_mul_toom3_start
 
static mulfunc_t bary_mul_karatsuba_start
 
static VALUE base36_power_cache [35][MAX_BASE36_POWER_TABLE_ENTRIES]
 
static size_t base36_numdigits_cache [35][MAX_BASE36_POWER_TABLE_ENTRIES]
 

Macro Definition Documentation

◆ ADV

#define ADV (   n)
Value:
do {\
if (len > 0 && len <= (n)) goto bad; \
str += (n); \
len -= (n); \
} while (0)
#define bad(x)
Definition: _sdbm.c:124
register unsigned int len
Definition: zonetab.h:51

Referenced by rb_cstr_parse_inum().

◆ ALIGNOF

#define ALIGNOF (   type)    ((int)offsetof(struct { char f1; type f2; }, f2))

Definition at line 67 of file bignum.c.

Referenced by bary_pack(), and bary_unpack_internal().

◆ ASSERT_LEN

#define ASSERT_LEN ( )
Value:
do {\
assert(len != 0); \
if (len0 >= 0) assert(s + len0 == str + len); \
} while (0)
#define assert(x)
Definition: dlmalloc.c:1176
register unsigned int len
Definition: zonetab.h:51

Referenced by rb_cstr_parse_inum().

◆ BARY_ADD

#define BARY_ADD (   z,
  x,
 
)    bary_add(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))

Definition at line 106 of file bignum.c.

Referenced by absint_numwords_generic().

◆ BARY_ARGS

#define BARY_ARGS (   ary)    ary, numberof(ary)

Definition at line 104 of file bignum.c.

Referenced by absint_numwords_generic(), and rb_big_bit_length().

◆ BARY_DIVMOD

#define BARY_DIVMOD (   q,
  r,
  x,
 
)    bary_divmod(BARY_ARGS(q), BARY_ARGS(r), BARY_ARGS(x), BARY_ARGS(y))

Definition at line 109 of file bignum.c.

Referenced by absint_numwords_generic().

◆ BARY_SHORT_MUL

#define BARY_SHORT_MUL (   z,
  x,
 
)    bary_short_mul(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))

Definition at line 108 of file bignum.c.

Referenced by absint_numwords_generic(), and rb_big_bit_length().

◆ BARY_SUB

#define BARY_SUB (   z,
  x,
 
)    bary_sub(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))

Definition at line 107 of file bignum.c.

Referenced by absint_numwords_generic(), and rb_big_bit_length().

◆ BARY_TRUNC

#define BARY_TRUNC (   ds,
 
)
Value:
do { \
while (0 < (n) && (ds)[(n)-1] == 0) \
(n)--; \
} while (0)

Definition at line 126 of file bignum.c.

Referenced by abs2twocomp(), bary_cmp(), bary_divmod(), bary_mul_toom3(), big2str_generic(), big2str_karatsuba(), bigdivrem(), bigfixize(), rb_big2str1(), rb_big_divrem_normal(), and str2big_karatsuba().

◆ BARY_ZERO_P

#define BARY_ZERO_P (   x)    bary_zero_p(BARY_ARGS(x))

Definition at line 110 of file bignum.c.

Referenced by absint_numwords_generic().

◆ BDIGIT_DBL_MAX

#define BDIGIT_DBL_MAX   (~(BDIGIT_DBL)0)

Definition at line 84 of file bignum.c.

Referenced by maxpow_in_bdigit_dbl().

◆ BDIGIT_MSB

#define BDIGIT_MSB (   d)    (((d) & BIGRAD_HALF) != 0)

Definition at line 79 of file bignum.c.

Referenced by bary_unpack_internal(), bigdivrem_restoring(), and rb_integer_unpack().

◆ bdigit_roomof

#define bdigit_roomof (   n)    roomof(n, SIZEOF_BDIGIT)

◆ BDIGITS

#define BDIGITS (   x)    (BIGNUM_DIGITS(x))

◆ BDIGITS_ZERO

#define BDIGITS_ZERO (   ptr,
 
)
Value:
do { \
BDIGIT *bdigitz_zero_ptr = (ptr); \
size_t bdigitz_zero_n = (n); \
while (bdigitz_zero_n) { \
*bdigitz_zero_ptr++ = 0; \
bdigitz_zero_n--; \
} \
} while (0)

Definition at line 117 of file bignum.c.

Referenced by bary_divmod(), bary_divmod_normal(), bary_mul_balance_with_mulfunc(), bary_mul_normal(), bary_mul_precheck(), bary_mul_single(), bary_mul_toom3(), bary_pack(), bary_sq_fast(), bary_unpack(), big_shift3(), rb_big_divrem_normal(), rb_big_mul_toom3(), str2big_karatsuba(), and str2big_normal().

◆ BDIGMAX

#define BDIGMAX   ((BDIGIT)(BIGRAD-1))

◆ BIGDIVREM_EXTRA_WORDS

#define BIGDIVREM_EXTRA_WORDS   1

◆ BIGDN

#define BIGDN (   x)    RSHIFT((x),BITSPERDIG)

◆ BIGLO

#define BIGLO (   x)    ((BDIGIT)((x) & BDIGMAX))

◆ bignew

#define bignew (   len,
  sign 
)    bignew_1(rb_cInteger,(len),(sign))

◆ BIGNUM_DEBUG

#define BIGNUM_DEBUG   0

Definition at line 2871 of file bignum.c.

◆ BIGNUM_SET_LEN

#define BIGNUM_SET_LEN (   b,
 
)
Value:
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
(void)(RBASIC(b)->flags = \
(RBASIC(b)->flags & ~BIGNUM_EMBED_LEN_MASK) | \
((l) << BIGNUM_EMBED_LEN_SHIFT)) : \
(void)(RBIGNUM(b)->as.heap.len = (l)))
#define BIGNUM_EMBED_LEN_MASK
Definition: internal.h:507
#define BIGNUM_EMBED_LEN_SHIFT
Definition: internal.h:508
#define RBIGNUM(obj)
Definition: internal.h:521
#define RBASIC(obj)
Definition: ruby.h:1204
#define BIGNUM_EMBED_FLAG
Definition: internal.h:506

Definition at line 2930 of file bignum.c.

Referenced by bignew_1(), rb_big_realloc(), rb_big_resize(), rb_str2big_karatsuba(), and rb_uint2big().

◆ BIGNUM_SET_NEGATIVE_SIGN

#define BIGNUM_SET_NEGATIVE_SIGN (   b)    BIGNUM_SET_SIGN(b, 0)

Definition at line 112 of file bignum.c.

Referenced by bigsub(), rb_big_comp(), rb_int2big(), and rb_str2big_karatsuba().

◆ BIGNUM_SET_POSITIVE_SIGN

#define BIGNUM_SET_POSITIVE_SIGN (   b)    BIGNUM_SET_SIGN(b, 1)

Definition at line 113 of file bignum.c.

Referenced by rb_big_abs(), and rb_big_comp().

◆ BIGRAD

#define BIGRAD   ((BDIGIT_DBL)1 << BITSPERDIG)

Definition at line 77 of file bignum.c.

Referenced by big2dbl(), and dbl2big().

◆ BIGRAD_HALF

#define BIGRAD_HALF   ((BDIGIT)(BIGRAD >> 1))

Definition at line 78 of file bignum.c.

◆ BIGSIZE

#define BIGSIZE (   x)
Value:
(BIGNUM_LEN(x) == 0 ? (size_t)0 : \
BDIGITS(x)[BIGNUM_LEN(x)-1] ? \
(size_t)(BIGNUM_LEN(x)*SIZEOF_BDIGIT - nlz(BDIGITS(x)[BIGNUM_LEN(x)-1])/CHAR_BIT) : \
#define BIGNUM_LEN(b)
Definition: internal.h:509
#define SIZEOF_BDIGIT
Definition: internal.h:426
#define BDIGITS(x)
Definition: bignum.c:75
size_t rb_absint_size(VALUE val, int *nlz_bits_ret)
Definition: bignum.c:3231
#define CHAR_BIT
Definition: ruby.h:196
static int nlz(BDIGIT x)
Definition: bignum.c:159
#define NULL
Definition: _sdbm.c:102

Definition at line 97 of file bignum.c.

Referenced by big2ulong(), rb_big2long(), rb_big_aref(), and rb_big_size().

◆ BIGUP

#define BIGUP (   x)    LSHIFTX(((x) + (BDIGIT_DBL)0), BITSPERDIG)

◆ BIGZEROP

#define BIGZEROP (   x)
Value:
(BIGNUM_LEN(x) == 0 || \
(BDIGITS(x)[0] == 0 && \
(BIGNUM_LEN(x) == 1 || bigzero_p(x))))
#define BIGNUM_LEN(b)
Definition: internal.h:509
#define BDIGITS(x)
Definition: bignum.c:75
static int bigzero_p(VALUE x)
Definition: bignum.c:2897

Definition at line 94 of file bignum.c.

Referenced by big_shift2(), bigdivmod(), rb_big_pow(), rb_bigzero_p(), and rb_cmpint().

◆ BITSPERDIG

#define BITSPERDIG   (SIZEOF_BDIGIT*CHAR_BIT)

◆ CLEAR_LOWBITS

#define CLEAR_LOWBITS (   d,
  numbits 
)    ((d) & LSHIFTX(~((d)*0), (numbits)))

Definition at line 71 of file bignum.c.

Referenced by bary_pack().

◆ conv_digit

#define conv_digit (   c)    (ruby_digit36_to_number_table[(unsigned char)(c)])

◆ DBL_BIGDIG

#define DBL_BIGDIG   ((DBL_MANT_DIG + BITSPERDIG) / BITSPERDIG)

Referenced by big_fdiv(), and big_fdiv_int().

◆ FILL_DD

#define FILL_DD   integer_pack_fill_dd(&dp, &de, &dd, &numbits_in_dd)

Referenced by bary_pack().

◆ FILL_LOWBITS

#define FILL_LOWBITS (   d,
  numbits 
)    ((d) | (LSHIFTX(((d)*0+1), (numbits))-1))

Definition at line 72 of file bignum.c.

Referenced by bary_pack().

◆ GMP_BIG2STR_DIGITS

#define GMP_BIG2STR_DIGITS   20

Definition at line 139 of file bignum.c.

Referenced by rb_big2str1().

◆ GMP_DIV_DIGITS

#define GMP_DIV_DIGITS   20

Definition at line 138 of file bignum.c.

Referenced by bary_divmod_branch().

◆ GMP_MUL_DIGITS

#define GMP_MUL_DIGITS   20

Definition at line 134 of file bignum.c.

Referenced by bary_mul(), and bigsq().

◆ GMP_STR2BIG_DIGITS

#define GMP_STR2BIG_DIGITS   20

Definition at line 140 of file bignum.c.

Referenced by rb_cstr_parse_inum().

◆ HOST_BIGENDIAN_P

#define HOST_BIGENDIAN_P   0

Definition at line 65 of file bignum.c.

Referenced by bary_pack(), and bary_unpack_internal().

◆ INTEGER_PACK_BYTEORDER_MASK

#define INTEGER_PACK_BYTEORDER_MASK
Value:
INTEGER_PACK_LSBYTE_FIRST | \
INTEGER_PACK_NATIVE_BYTE_ORDER)
#define INTEGER_PACK_MSBYTE_FIRST
Definition: intern.h:140

Definition at line 484 of file bignum.c.

Referenced by bary_pack(), bary_unpack_internal(), integer_pack_loop_setup(), and validate_integer_pack_format().

◆ INTEGER_PACK_WORDORDER_MASK

#define INTEGER_PACK_WORDORDER_MASK
Value:
INTEGER_PACK_LSWORD_FIRST)
#define INTEGER_PACK_MSWORD_FIRST
Definition: intern.h:138

Definition at line 481 of file bignum.c.

Referenced by bary_pack(), bary_unpack_internal(), integer_pack_loop_setup(), and validate_integer_pack_format().

◆ KARATSUBA_BALANCED

#define KARATSUBA_BALANCED (   xn,
  yn 
)    ((yn)/2 < (xn))

◆ KARATSUBA_MUL_DIGITS

#define KARATSUBA_MUL_DIGITS   70

Definition at line 135 of file bignum.c.

Referenced by bary_mul(), bary_mul_karatsuba_branch(), bigsq(), and rb_cstr_parse_inum().

◆ LSHIFTABLE

#define LSHIFTABLE (   d,
 
)    ((n) < sizeof(d) * CHAR_BIT)

Definition at line 69 of file bignum.c.

◆ LSHIFTX

#define LSHIFTX (   d,
 
)    (!LSHIFTABLE(d, n) ? 0 : ((d) << (!LSHIFTABLE(d, n) ? 0 : (n))))

Definition at line 70 of file bignum.c.

Referenced by integer_unpack_single_bdigit().

◆ MAX_BASE36_POWER_TABLE_ENTRIES

#define MAX_BASE36_POWER_TABLE_ENTRIES   (SIZEOF_SIZE_T * CHAR_BIT + 1)

Definition at line 4597 of file bignum.c.

Referenced by big2str_generic(), power_cache_get_power(), and power_cache_init().

◆ ON_DEBUG

#define ON_DEBUG (   x)

Definition at line 2893 of file bignum.c.

◆ POW2_P

#define POW2_P (   x)    (((x)&((x)-1))==0)

◆ PUSH_BITS

#define PUSH_BITS (   data,
  numbits 
)    integer_unpack_push_bits(data, numbits, &dd, &numbits_in_dd, &dp)

Referenced by bary_unpack_internal().

◆ RB_BIGNUM_TYPE_P

#define RB_BIGNUM_TYPE_P (   x)    RB_TYPE_P((x), T_BIGNUM)

◆ SIZEOF_BDIGIT_DBL

#define SIZEOF_BDIGIT_DBL   SIZEOF_LONG_LONG

Definition at line 41 of file bignum.c.

Referenced by big2str_2bdigits().

◆ TAKE_LOWBITS

#define TAKE_LOWBITS (   n)    integer_pack_take_lowbits(n, &dd, &numbits_in_dd)

Referenced by bary_pack().

◆ TOOM3_BALANCED

#define TOOM3_BALANCED (   xn,
  yn 
)    (((yn)+2)/3 * 2 < (xn))

◆ TOOM3_MUL_DIGITS

#define TOOM3_MUL_DIGITS   150

Definition at line 136 of file bignum.c.

Referenced by bary_mul_toom3_branch().

◆ U16

#define U16 (   a)    ((uint16_t)(a))

Definition at line 168 of file bignum.c.

◆ U32

#define U32 (   a)    ((uint32_t)(a))

Definition at line 169 of file bignum.c.

Typedef Documentation

◆ mulfunc_t

typedef void() mulfunc_t(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, const BDIGIT *yds, size_t yn, BDIGIT *wds, size_t wn)

Definition at line 142 of file bignum.c.

Enumeration Type Documentation

◆ big_op_t

enum big_op_t
Enumerator
big_op_gt 
big_op_ge 
big_op_lt 
big_op_le 

Definition at line 5373 of file bignum.c.

Function Documentation

◆ abs2twocomp()

static BDIGIT abs2twocomp ( VALUE xp,
long *  n_ret 
)
static

◆ absint_numwords_generic()

static size_t absint_numwords_generic ( size_t  numbytes,
int  nlz_bits_in_msbyte,
size_t  word_numbits,
size_t *  nlz_bits_ret 
)
static

◆ absint_numwords_small()

static size_t absint_numwords_small ( size_t  numbytes,
int  nlz_bits_in_msbyte,
size_t  word_numbits,
size_t *  nlz_bits_ret 
)
static

Definition at line 3278 of file bignum.c.

References CHAR_BIT, div, and mod.

Referenced by rb_absint_numwords().

◆ bary2bdigitdbl()

static BDIGIT_DBL bary2bdigitdbl ( const BDIGIT ds,
size_t  n 
)
inlinestatic

Definition at line 360 of file bignum.c.

References assert, and BIGUP.

Referenced by bary_divmod(), big2str_2bdigits(), and bigdivrem().

◆ bary_2comp()

static int bary_2comp ( BDIGIT ds,
size_t  n 
)
static

◆ bary_add()

static int bary_add ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

◆ bary_add_one()

static int bary_add_one ( BDIGIT ds,
size_t  n 
)
static

Definition at line 1428 of file bignum.c.

References BIGLO.

Referenced by bary_mul_karatsuba(), and rb_big_comp().

◆ bary_addc()

static int bary_addc ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
int  carry 
)
static

Definition at line 1376 of file bignum.c.

References assert, BDIGIT, BDIGIT_DBL, BIGDN, and BIGLO.

Referenced by bary_add(), and bary_mul_karatsuba().

◆ bary_cmp()

static int bary_cmp ( const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

Definition at line 381 of file bignum.c.

References BARY_TRUNC, and BDIGIT.

Referenced by big2str_karatsuba(), and rb_big_cmp().

◆ bary_divmod()

static void bary_divmod ( BDIGIT qds,
size_t  qn,
BDIGIT rds,
size_t  rn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

◆ bary_divmod_branch()

static void bary_divmod_branch ( BDIGIT qds,
size_t  qn,
BDIGIT rds,
size_t  rn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

Definition at line 2814 of file bignum.c.

References bary_divmod_normal(), and GMP_DIV_DIGITS.

Referenced by bary_divmod(), and bigdivrem().

◆ bary_divmod_normal()

static void bary_divmod_normal ( BDIGIT qds,
size_t  qn,
BDIGIT rds,
size_t  rn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

◆ bary_mul()

static void bary_mul ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

◆ bary_mul_balance_with_mulfunc()

static void bary_mul_balance_with_mulfunc ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
BDIGIT wds,
size_t  wn,
mulfunc_t mulfunc 
)
static

◆ bary_mul_karatsuba()

static void bary_mul_karatsuba ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
BDIGIT wds,
size_t  wn 
)
static

◆ bary_mul_karatsuba_branch()

static void bary_mul_karatsuba_branch ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
BDIGIT wds,
size_t  wn 
)
static

◆ bary_mul_karatsuba_start()

static void bary_mul_karatsuba_start ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
BDIGIT wds,
size_t  wn 
)
static

Definition at line 2454 of file bignum.c.

References bary_mul_karatsuba_branch(), and bary_mul_precheck().

◆ bary_mul_normal()

static void bary_mul_normal ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

Definition at line 1527 of file bignum.c.

References assert, bary_muladd_1xN(), and BDIGITS_ZERO.

Referenced by bary_mul_precheck(), bary_short_mul(), and rb_big_mul_normal().

◆ bary_mul_precheck()

static int bary_mul_precheck ( BDIGIT **  zdsp,
size_t *  znp,
const BDIGIT **  xdsp,
size_t *  xnp,
const BDIGIT **  ydsp,
size_t *  ynp 
)
static

◆ bary_mul_single()

static void bary_mul_single ( BDIGIT zds,
size_t  zn,
BDIGIT  x,
BDIGIT  y 
)
static

Definition at line 1440 of file bignum.c.

References assert, BDIGIT_DBL, bdigitdbl2bary(), and BDIGITS_ZERO.

Referenced by bary_short_mul().

◆ bary_mul_toom3()

static void bary_mul_toom3 ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
BDIGIT wds,
size_t  wn 
)
static

◆ bary_mul_toom3_branch()

static void bary_mul_toom3_branch ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
BDIGIT wds,
size_t  wn 
)
static

◆ bary_mul_toom3_start()

static void bary_mul_toom3_start ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
BDIGIT wds,
size_t  wn 
)
static

Definition at line 2479 of file bignum.c.

References bary_mul_precheck(), and bary_mul_toom3_branch().

◆ bary_muladd_1xN()

static int bary_muladd_1xN ( BDIGIT zds,
size_t  zn,
BDIGIT  x,
const BDIGIT yds,
size_t  yn 
)
static

Definition at line 1452 of file bignum.c.

References assert, BDIGIT_DBL, BDIGIT_DBL_SIGNED, BIGDN, and BIGLO.

Referenced by bary_mul_karatsuba(), bary_mul_normal(), and bary_mul_toom3().

◆ bary_mulsub_1xN()

static int bary_mulsub_1xN ( BDIGIT zds,
size_t  zn,
BDIGIT  x,
const BDIGIT yds,
size_t  yn 
)
static

Definition at line 1513 of file bignum.c.

References assert, BDIGIT_DBL_SIGNED, bigdivrem_mulsub(), BIGDN, and BIGLO.

Referenced by bary_mul_toom3().

◆ bary_neg()

static void bary_neg ( BDIGIT ds,
size_t  n 
)
static

Definition at line 442 of file bignum.c.

References BIGLO.

Referenced by rb_big_comp().

◆ bary_pack()

static int bary_pack ( int  sign,
BDIGIT ds,
size_t  num_bdigits,
void *  words,
size_t  numwords,
size_t  wordsize,
size_t  nails,
int  flags 
)
static

◆ bary_short_mul()

static void bary_short_mul ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

Definition at line 2299 of file bignum.c.

References assert, bary_mul_normal(), bary_mul_single(), and rb_thread_check_ints().

Referenced by bary_mul(), and bary_mul_karatsuba_branch().

◆ bary_small_lshift()

static BDIGIT bary_small_lshift ( BDIGIT zds,
const BDIGIT xds,
size_t  n,
int  shift 
)
static

◆ bary_small_rshift()

static void bary_small_rshift ( BDIGIT zds,
const BDIGIT xds,
size_t  n,
int  shift,
BDIGIT  higher_bdigit 
)
static

◆ bary_sparse_p()

static int bary_sparse_p ( const BDIGIT ds,
size_t  n 
)
inlinestatic

Definition at line 2314 of file bignum.c.

References rb_genrand_ulong_limited().

Referenced by bary_mul_karatsuba_branch().

◆ bary_sq_fast()

static void bary_sq_fast ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn 
)
static

Definition at line 1555 of file bignum.c.

References assert, BDIGIT, BDIGIT_DBL, BDIGITS_ZERO, BIGDN, and BIGLO.

Referenced by bary_mul(), bary_mul_karatsuba_branch(), bigsq(), and rb_big_sq_fast().

◆ bary_sub()

static int bary_sub ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn 
)
static

Definition at line 1364 of file bignum.c.

References bary_subb().

Referenced by bary_mul_karatsuba(), bary_mul_toom3(), and bigsub().

◆ bary_sub_one()

static int bary_sub_one ( BDIGIT zds,
size_t  zn 
)
static

Definition at line 1370 of file bignum.c.

References bary_subb(), and NULL.

Referenced by bary_mul_karatsuba().

◆ bary_subb()

static int bary_subb ( BDIGIT zds,
size_t  zn,
const BDIGIT xds,
size_t  xn,
const BDIGIT yds,
size_t  yn,
int  borrow 
)
static

Definition at line 1313 of file bignum.c.

References assert, BDIGIT_DBL_SIGNED, BDIGMAX, BIGDN, and BIGLO.

Referenced by bary_sub(), and bary_sub_one().

◆ bary_swap()

static void bary_swap ( BDIGIT ds,
size_t  num_bdigits 
)
static

Definition at line 470 of file bignum.c.

References BDIGIT.

Referenced by bary_pack(), and bary_unpack_internal().

◆ bary_unpack()

static void bary_unpack ( BDIGIT bdigits,
size_t  num_bdigits,
const void *  words,
size_t  numwords,
size_t  wordsize,
size_t  nails,
int  flags 
)
static

◆ bary_unpack_internal()

static int bary_unpack_internal ( BDIGIT bdigits,
size_t  num_bdigits,
const void *  words,
size_t  numwords,
size_t  wordsize,
size_t  nails,
int  flags,
int  nlp_bits 
)
static

◆ bary_zero_p()

static int bary_zero_p ( BDIGIT xds,
size_t  xn 
)
static

◆ bdigitdbl2bary()

static void bdigitdbl2bary ( BDIGIT ds,
size_t  n,
BDIGIT_DBL  num 
)
inlinestatic

Definition at line 372 of file bignum.c.

References assert, BDIGIT, BIGDN, and BIGLO.

Referenced by bary_mul_single(), and power_cache_get_power().

◆ big2dbl()

static double big2dbl ( VALUE  x)
static

◆ big2str_2bdigits()

static void big2str_2bdigits ( struct big2str_struct b2s,
BDIGIT xds,
size_t  xn,
size_t  taillen 
)
static

◆ big2str_alloc()

static void big2str_alloc ( struct big2str_struct b2s,
size_t  len 
)
static

◆ big2str_base_poweroftwo()

static VALUE big2str_base_poweroftwo ( VALUE  x,
int  base 
)
static

◆ big2str_generic()

static VALUE big2str_generic ( VALUE  x,
int  base 
)
static

◆ big2str_karatsuba()

static void big2str_karatsuba ( struct big2str_struct b2s,
BDIGIT xds,
size_t  xn,
size_t  wn,
int  power_level,
size_t  taillen 
)
static

◆ big2ulong()

static unsigned long big2ulong ( VALUE  x,
const char *  type 
)
static

Definition at line 5047 of file bignum.c.

References BDIGIT, BDIGITS, BIGNUM_LEN, BIGSIZE, BITSPERDIG, len, rb_eRangeError, and rb_raise().

Referenced by rb_big2long(), rb_big2ulong(), and rb_big_aref().

◆ big_extend_carry()

static void big_extend_carry ( VALUE  x)
static

Definition at line 3014 of file bignum.c.

References BDIGITS, BIGNUM_LEN, and rb_big_resize().

Referenced by get2comp(), rb_big_comp(), and rb_integer_unpack().

◆ big_fdiv()

static double big_fdiv ( VALUE  x,
VALUE  y,
long  ey 
)
static

◆ big_fdiv_float()

static double big_fdiv_float ( VALUE  x,
VALUE  y 
)
static

Definition at line 6131 of file bignum.c.

References big_fdiv(), dbl2big(), DBL_MANT_DIG, and RFLOAT_VALUE.

Referenced by rb_big_fdiv_double().

◆ big_fdiv_int()

static double big_fdiv_int ( VALUE  x,
VALUE  y 
)
static

Definition at line 6119 of file bignum.c.

References BDIGITS, big_fdiv(), big_shift(), BIGNUM_LEN, bigtrunc(), BITSPERDIG, DBL_BIGDIG, and nlz().

Referenced by rb_big_fdiv_double().

◆ big_lshift()

static VALUE big_lshift ( VALUE  x,
unsigned long  shift 
)
static

Definition at line 4582 of file bignum.c.

References big_shift3(), and BITSPERDIG.

Referenced by big_shift().

◆ big_op()

static VALUE big_op ( VALUE  x,
VALUE  y,
enum big_op_t  op 
)
static

◆ big_rshift()

static VALUE big_rshift ( VALUE  x,
unsigned long  shift 
)
static

Definition at line 4590 of file bignum.c.

References big_shift3(), and BITSPERDIG.

Referenced by big_shift().

◆ big_shift()

static VALUE big_shift ( VALUE  x,
long  n 
)
static

Definition at line 6082 of file bignum.c.

References big_lshift(), and big_rshift().

Referenced by big_fdiv(), and big_fdiv_int().

◆ big_shift2()

static VALUE big_shift2 ( VALUE  x,
int  lshift_p,
VALUE  y 
)
static

◆ big_shift3()

static VALUE big_shift3 ( VALUE  x,
int  lshift_p,
size_t  shift_numdigits,
int  shift_numbits 
)
static

◆ bigadd()

static VALUE bigadd ( VALUE  x,
VALUE  y,
int  sign 
)
static

Definition at line 5724 of file bignum.c.

References bary_add(), BDIGITS, bignew, BIGNUM_LEN, BIGNUM_SIGN, bigsub(), and len.

Referenced by bigdivmod(), rb_big_minus(), and rb_big_plus().

◆ bigadd_int()

static VALUE bigadd_int ( VALUE  x,
long  y 
)
static

◆ bigand_int()

static VALUE bigand_int ( VALUE  x,
long  xn,
BDIGIT  hibitsx,
long  y 
)
static

◆ bigdivmod()

static void bigdivmod ( VALUE  x,
VALUE  y,
volatile VALUE divp,
volatile VALUE modp 
)
static

Definition at line 5978 of file bignum.c.

References bigadd(), bigdivrem(), BIGNUM_SIGN, BIGZEROP, mod, and rb_int2big().

Referenced by rb_big_divide(), rb_big_divmod(), and rb_big_modulo().

◆ bigdivrem()

static VALUE bigdivrem ( VALUE  x,
VALUE  y,
volatile VALUE divp,
volatile VALUE modp 
)
static

◆ bigdivrem1()

static void* bigdivrem1 ( void *  ptr)
static

◆ bigdivrem_mulsub()

static BDIGIT_DBL_SIGNED bigdivrem_mulsub ( BDIGIT zds,
size_t  zn,
BDIGIT  x,
const BDIGIT yds,
size_t  yn 
)
static

Definition at line 1487 of file bignum.c.

References assert, BDIGIT_DBL, BDIGIT_DBL_SIGNED, BIGDN, and BIGLO.

Referenced by bary_mulsub_1xN(), and bigdivrem1().

◆ bigdivrem_restoring()

static void bigdivrem_restoring ( BDIGIT zds,
size_t  zn,
BDIGIT yds,
size_t  yn 
)
static

◆ bigdivrem_single()

static BDIGIT bigdivrem_single ( BDIGIT qds,
const BDIGIT xds,
size_t  xn,
BDIGIT  y 
)
static

Definition at line 2592 of file bignum.c.

References bigdivrem_single1().

Referenced by bary_divmod(), bary_mul_toom3(), and bigdivrem().

◆ bigdivrem_single1()

static BDIGIT bigdivrem_single1 ( BDIGIT qds,
const BDIGIT xds,
size_t  xn,
BDIGIT  x_higher_bdigit,
BDIGIT  y 
)
static

Definition at line 2567 of file bignum.c.

References assert, bary_small_rshift(), BDIGIT, BDIGIT_DBL, BIGUP, bit_length, and POW2_P.

Referenced by bigdivrem_restoring(), and bigdivrem_single().

◆ bigfixize()

static VALUE bigfixize ( VALUE  x)
inlinestatic

◆ bigmul0()

static VALUE bigmul0 ( VALUE  x,
VALUE  y 
)
static

◆ bignew_1()

static VALUE bignew_1 ( VALUE  klass,
size_t  len,
int  sign 
)
static

◆ bignorm()

static VALUE bignorm ( VALUE  x)
static

◆ bigor_int()

static VALUE bigor_int ( VALUE  x,
long  xn,
BDIGIT  hibitsx,
long  y 
)
static

◆ bigsq()

static VALUE bigsq ( VALUE  x)
static

◆ bigsub()

static VALUE bigsub ( VALUE  x,
VALUE  y 
)
static

◆ bigsub_int()

static VALUE bigsub_int ( VALUE  x,
long  y0 
)
static

◆ bigtrunc()

static VALUE bigtrunc ( VALUE  x)
inlinestatic

◆ bigxor_int()

static VALUE bigxor_int ( VALUE  x,
long  xn,
BDIGIT  hibitsx,
long  y 
)
static

◆ bigzero_p()

static int bigzero_p ( VALUE  x)
static

Definition at line 2897 of file bignum.c.

References bary_zero_p(), BDIGITS, and BIGNUM_LEN.

◆ bytes_2comp()

static int bytes_2comp ( unsigned char *  buf,
size_t  len 
)
static

Definition at line 612 of file bignum.c.

References len.

Referenced by bary_pack().

◆ dbl2big()

static VALUE dbl2big ( double  d)
static

Definition at line 5161 of file bignum.c.

References BDIGIT, BDIGITS, bignew, BIGRAD, isinf(), isnan, rb_eFloatDomainError, and rb_raise().

Referenced by big_fdiv_float(), and rb_dbl2big().

◆ get2comp()

static void get2comp ( VALUE  x)
static

Definition at line 3022 of file bignum.c.

References bary_2comp(), BDIGIT, BDIGITS, big_extend_carry(), and BIGNUM_LEN.

Referenced by bigsub_int(), rb_big_2comp(), and twocomp2abs_bang().

◆ Init_Bignum()

void Init_Bignum ( void  )

◆ integer_pack_fill_dd()

static void integer_pack_fill_dd ( BDIGIT **  dpp,
BDIGIT **  dep,
BDIGIT_DBL ddp,
int *  numbits_in_dd_p 
)
inlinestatic

Definition at line 588 of file bignum.c.

References BDIGIT_DBL, BITSPERDIG, and CHAR_BIT.

◆ integer_pack_loop_setup()

static void integer_pack_loop_setup ( size_t  numwords,
size_t  wordsize,
size_t  nails,
int  flags,
size_t *  word_num_fullbytes_ret,
int *  word_num_partialbits_ret,
size_t *  word_start_ret,
ssize_t *  word_step_ret,
size_t *  word_last_ret,
size_t *  byte_start_ret,
int *  byte_step_ret 
)
static

◆ integer_pack_take_lowbits()

static BDIGIT_DBL integer_pack_take_lowbits ( int  n,
BDIGIT_DBL ddp,
int *  numbits_in_dd_p 
)
inlinestatic

Definition at line 601 of file bignum.c.

References BDIGIT_DBL.

◆ integer_unpack_num_bdigits()

static size_t integer_unpack_num_bdigits ( size_t  numwords,
size_t  wordsize,
size_t  nails,
int *  nlp_bits_ret 
)
static

◆ integer_unpack_num_bdigits_generic()

static size_t integer_unpack_num_bdigits_generic ( size_t  numwords,
size_t  wordsize,
size_t  nails,
int *  nlp_bits_ret 
)
static

Definition at line 968 of file bignum.c.

References BITSPERDIG, CHAR_BIT, r1, r2, and r3.

Referenced by integer_unpack_num_bdigits().

◆ integer_unpack_num_bdigits_small()

static size_t integer_unpack_num_bdigits_small ( size_t  numwords,
size_t  wordsize,
size_t  nails,
int *  nlp_bits_ret 
)
static

Definition at line 958 of file bignum.c.

References BITSPERDIG, and CHAR_BIT.

Referenced by integer_unpack_num_bdigits().

◆ integer_unpack_push_bits()

static void integer_unpack_push_bits ( int  data,
int  numbits,
BDIGIT_DBL ddp,
int *  numbits_in_dd_p,
BDIGIT **  dpp 
)
inlinestatic

Definition at line 1050 of file bignum.c.

References BDIGIT_DBL, BIGDN, BIGLO, and BITSPERDIG.

◆ integer_unpack_single_bdigit()

static int integer_unpack_single_bdigit ( BDIGIT  u,
size_t  size,
int  flags,
BDIGIT dp 
)
static

Definition at line 1062 of file bignum.c.

References BDIGMAX, BIGLO, CHAR_BIT, INTEGER_PACK_2COMP, INTEGER_PACK_NEGATIVE, LSHIFTX, and SIZEOF_BDIGIT.

Referenced by bary_unpack_internal().

◆ invalid_integer()

static void invalid_integer ( VALUE  s)
inlinestatic

◆ invalid_radix()

static void invalid_radix ( int  base)
inlinestatic

◆ maxpow_in_bdigit_dbl()

static BDIGIT_DBL maxpow_in_bdigit_dbl ( int  base,
int *  exp_ret 
)
static

◆ nlz()

static int nlz ( BDIGIT  x)
static

◆ NORETURN() [1/2]

NORETURN ( static inline void   invalid_radixint base)

◆ NORETURN() [2/2]

NORETURN ( static inline void   invalid_integerVALUE s)

◆ power_cache_get_power()

static VALUE power_cache_get_power ( int  base,
int  power_level,
size_t *  numdigits_ret 
)
inlinestatic

◆ power_cache_init()

static void power_cache_init ( void  )
static

Definition at line 4603 of file bignum.c.

References MAX_BASE36_POWER_TABLE_ENTRIES, and Qnil.

Referenced by Init_Bignum().

◆ rb_absint_numwords()

size_t rb_absint_numwords ( VALUE  val,
size_t  word_numbits,
size_t *  nlz_bits_ret 
)

◆ rb_absint_singlebit_p()

int rb_absint_singlebit_p ( VALUE  val)

Definition at line 3430 of file bignum.c.

References BDIGIT, bdigit_roomof, BDIGITS, BIGDN, BIGLO, BIGNUM_LEN, dp, FIX2LONG, FIXNUM_P, numberof, POW2_P, and rb_to_int().

Referenced by rb_big_bit_length(), and rb_str_format().

◆ rb_absint_size()

size_t rb_absint_size ( VALUE  val,
int *  nlz_bits_ret 
)

◆ rb_big2dbl()

double rb_big2dbl ( VALUE  x)

◆ rb_big2long()

long rb_big2long ( VALUE  x)

◆ rb_big2str()

VALUE rb_big2str ( VALUE  x,
int  base 
)

Definition at line 5041 of file bignum.c.

References rb_big2str1().

Referenced by format_value(), GetVpValueWithPrec(), rb_int2str(), and rb_str_format().

◆ rb_big2str1()

static VALUE rb_big2str1 ( VALUE  x,
int  base 
)
static

◆ rb_big2str_generic()

VALUE rb_big2str_generic ( VALUE  x,
int  base 
)

◆ rb_big2str_poweroftwo()

VALUE rb_big2str_poweroftwo ( VALUE  x,
int  base 
)

Definition at line 4871 of file bignum.c.

References big2str_base_poweroftwo().

◆ rb_big2ulong()

unsigned long rb_big2ulong ( VALUE  x)

Definition at line 5072 of file bignum.c.

References big2ulong(), BIGNUM_POSITIVE_P, LONG_MIN, rb_eRangeError, and rb_raise().

Referenced by rb_num2ulong_internal(), and rb_num_to_uint().

◆ rb_big_2comp()

void rb_big_2comp ( VALUE  x)

Definition at line 3033 of file bignum.c.

References BDIGIT, and get2comp().

◆ rb_big_abs()

VALUE rb_big_abs ( VALUE  x)

Definition at line 6685 of file bignum.c.

References BIGNUM_NEGATIVE_P, BIGNUM_SET_POSITIVE_SIGN, and rb_big_clone().

Referenced by rb_int_abs().

◆ rb_big_and()

VALUE rb_big_and ( VALUE  x,
VALUE  y 
)

◆ rb_big_aref()

VALUE rb_big_aref ( VALUE  x,
VALUE  y 
)

◆ rb_big_bit_length()

VALUE rb_big_bit_length ( VALUE  big)

◆ rb_big_clone()

VALUE rb_big_clone ( VALUE  x)

Definition at line 3004 of file bignum.c.

References BDIGIT, BDIGITS, bignew_1(), BIGNUM_LEN, BIGNUM_SIGN, CLASS_OF, len, and MEMCPY.

Referenced by rb_big_abs(), rb_big_comp(), and rb_big_uminus().

◆ rb_big_cmp()

VALUE rb_big_cmp ( VALUE  x,
VALUE  y 
)

◆ rb_big_comp()

VALUE rb_big_comp ( VALUE  x)

◆ rb_big_div()

VALUE rb_big_div ( VALUE  x,
VALUE  y 
)

Definition at line 6022 of file bignum.c.

References rb_big_divide().

Referenced by fix_divide(), and rb_int_div().

◆ rb_big_divide()

static VALUE rb_big_divide ( VALUE  x,
VALUE  y,
ID  op 
)
static

◆ rb_big_divmod()

VALUE rb_big_divmod ( VALUE  x,
VALUE  y 
)

◆ rb_big_divrem_normal()

VALUE rb_big_divrem_normal ( VALUE  x,
VALUE  y 
)

◆ rb_big_eq()

VALUE rb_big_eq ( VALUE  x,
VALUE  y 
)

◆ rb_big_eql()

VALUE rb_big_eql ( VALUE  x,
VALUE  y 
)

Definition at line 5471 of file bignum.c.

References BDIGIT, BDIGITS, BIGNUM_LEN, BIGNUM_SIGN, MEMCMP, Qfalse, Qtrue, and RB_BIGNUM_TYPE_P.

Referenced by num_eql().

◆ rb_big_even_p()

VALUE rb_big_even_p ( VALUE  num)

Definition at line 6763 of file bignum.c.

References BDIGITS, BIGNUM_LEN, Qfalse, and Qtrue.

Referenced by int_even_p().

◆ rb_big_fdiv()

VALUE rb_big_fdiv ( VALUE  x,
VALUE  y 
)

Definition at line 6168 of file bignum.c.

References DBL2NUM, and rb_big_fdiv_double().

◆ rb_big_fdiv_double()

double rb_big_fdiv_double ( VALUE  x,
VALUE  y 
)

◆ rb_big_ge()

VALUE rb_big_ge ( VALUE  x,
VALUE  y 
)

Definition at line 5422 of file bignum.c.

References big_op(), and big_op_ge.

Referenced by rb_int_ge().

◆ rb_big_gt()

VALUE rb_big_gt ( VALUE  x,
VALUE  y 
)

Definition at line 5416 of file bignum.c.

References big_op(), and big_op_gt.

Referenced by rb_int_gt().

◆ rb_big_hash()

VALUE rb_big_hash ( VALUE  x)

Definition at line 6649 of file bignum.c.

References BDIGIT, BDIGITS, BIGNUM_LEN, BIGNUM_SIGN, hash(), rb_memhash(), and ST2FIX.

Referenced by any_hash().

◆ rb_big_idiv()

VALUE rb_big_idiv ( VALUE  x,
VALUE  y 
)

Definition at line 6028 of file bignum.c.

References rb_big_divide(), and rb_intern.

Referenced by rb_int_idiv().

◆ rb_big_le()

VALUE rb_big_le ( VALUE  x,
VALUE  y 
)

Definition at line 5434 of file bignum.c.

References big_op(), and big_op_le.

Referenced by int_le().

◆ rb_big_lshift()

VALUE rb_big_lshift ( VALUE  x,
VALUE  y 
)

◆ rb_big_lt()

VALUE rb_big_lt ( VALUE  x,
VALUE  y 
)

Definition at line 5428 of file bignum.c.

References big_op(), and big_op_lt.

Referenced by int_lt().

◆ rb_big_minus()

VALUE rb_big_minus ( VALUE  x,
VALUE  y 
)

◆ rb_big_modulo()

VALUE rb_big_modulo ( VALUE  x,
VALUE  y 
)

Definition at line 6034 of file bignum.c.

References bigdivmod(), bignorm(), FIX2LONG, FIXNUM_P, RB_BIGNUM_TYPE_P, rb_int2big(), and rb_num_coerce_bin().

Referenced by fix_mod(), mod(), and rb_int_modulo().

◆ rb_big_mul()

VALUE rb_big_mul ( VALUE  x,
VALUE  y 
)

◆ rb_big_mul_balance()

VALUE rb_big_mul_balance ( VALUE  x,
VALUE  y 
)

◆ rb_big_mul_karatsuba()

VALUE rb_big_mul_karatsuba ( VALUE  x,
VALUE  y 
)

◆ rb_big_mul_normal()

VALUE rb_big_mul_normal ( VALUE  x,
VALUE  y 
)

Definition at line 1540 of file bignum.c.

References bary_mul_normal(), BDIGITS, bignew, BIGNUM_LEN, BIGNUM_SIGN, and RB_GC_GUARD.

◆ rb_big_mul_toom3()

VALUE rb_big_mul_toom3 ( VALUE  x,
VALUE  y 
)

◆ rb_big_new()

VALUE rb_big_new ( size_t  len,
int  sign 
)

Definition at line 2998 of file bignum.c.

References bignew.

◆ rb_big_norm()

VALUE rb_big_norm ( VALUE  x)

Definition at line 3136 of file bignum.c.

References bignorm().

Referenced by fix_aref(), negate_lit(), rand_range(), and rb_int_digits_bigbase().

◆ rb_big_odd_p()

VALUE rb_big_odd_p ( VALUE  num)

Definition at line 6754 of file bignum.c.

References BDIGITS, BIGNUM_LEN, Qfalse, and Qtrue.

Referenced by int_odd_p().

◆ rb_big_or()

VALUE rb_big_or ( VALUE  x,
VALUE  y 
)

◆ rb_big_pack()

void rb_big_pack ( VALUE  val,
unsigned long *  buf,
long  num_longs 
)

◆ rb_big_plus()

VALUE rb_big_plus ( VALUE  x,
VALUE  y 
)

◆ rb_big_pow()

VALUE rb_big_pow ( VALUE  x,
VALUE  y 
)

◆ rb_big_realloc()

static void rb_big_realloc ( VALUE  big,
size_t  len 
)
static

◆ rb_big_remainder()

VALUE rb_big_remainder ( VALUE  x,
VALUE  y 
)

◆ rb_big_resize()

void rb_big_resize ( VALUE  big,
size_t  len 
)

Definition at line 2973 of file bignum.c.

References BIGNUM_SET_LEN, and rb_big_realloc().

Referenced by big_extend_carry(), bigfixize(), and bigtrunc().

◆ rb_big_rshift()

VALUE rb_big_rshift ( VALUE  x,
VALUE  y 
)

◆ rb_big_sign()

int rb_big_sign ( VALUE  x)

Definition at line 6695 of file bignum.c.

References BIGNUM_SIGN.

◆ rb_big_size()

size_t rb_big_size ( VALUE  big)

Definition at line 6701 of file bignum.c.

References BIGSIZE.

Referenced by int_round_zero_p(), and rb_big_size_m().

◆ rb_big_size_m()

VALUE rb_big_size_m ( VALUE  big)

Definition at line 6707 of file bignum.c.

References rb_big_size(), and SIZET2NUM.

Referenced by int_size().

◆ rb_big_sq_fast()

VALUE rb_big_sq_fast ( VALUE  x)

Definition at line 1609 of file bignum.c.

References bary_sq_fast(), BDIGITS, bignew, BIGNUM_LEN, and RB_GC_GUARD.

◆ rb_big_stop()

static void rb_big_stop ( void *  ptr)
static

Definition at line 2560 of file bignum.c.

References BDIGIT, Qtrue, and big_div_struct::stop.

Referenced by bigdivrem_restoring().

◆ rb_big_uminus()

VALUE rb_big_uminus ( VALUE  x)

Definition at line 5481 of file bignum.c.

References bignorm(), BIGNUM_NEGATE, and rb_big_clone().

Referenced by rand_int(), rb_int_uminus(), and rb_str_format().

◆ rb_big_unpack()

VALUE rb_big_unpack ( unsigned long *  buf,
long  num_longs 
)

◆ rb_big_xor()

VALUE rb_big_xor ( VALUE  x,
VALUE  y 
)

◆ rb_bigzero_p()

int rb_bigzero_p ( VALUE  x)

Definition at line 2903 of file bignum.c.

References BIGZEROP.

Referenced by num_positive_p(), num_zero_p(), rand_int(), and rand_range().

◆ rb_cmpint()

int rb_cmpint ( VALUE  val,
VALUE  a,
VALUE  b 
)

◆ rb_cstr2inum()

VALUE rb_cstr2inum ( const char *  str,
int  base 
)

Definition at line 4488 of file bignum.c.

References rb_cstr_to_inum().

Referenced by JSON_parse_integer().

◆ rb_cstr_parse_inum()

VALUE rb_cstr_parse_inum ( const char *  str,
ssize_t  len,
char **  endp,
int  base 
)

◆ rb_cstr_to_inum()

VALUE rb_cstr_to_inum ( const char *  str,
int  base,
int  badcheck 
)

◆ rb_dbl2big()

VALUE rb_dbl2big ( double  d)

◆ rb_int2big()

VALUE rb_int2big ( SIGNED_VALUE  n)

◆ rb_int2inum()

VALUE rb_int2inum ( SIGNED_VALUE  n)

Definition at line 3192 of file bignum.c.

References FIXABLE, LONG2FIX, and rb_int2big().

Referenced by dir_each(), and gzfile_reader_rewind().

◆ rb_int_coerce()

static VALUE rb_int_coerce ( VALUE  x,
VALUE  y 
)
static

Definition at line 6672 of file bignum.c.

References rb_assoc_new(), rb_Float(), and RB_INTEGER_TYPE_P.

Referenced by Init_Bignum().

◆ rb_integer_float_cmp()

VALUE rb_integer_float_cmp ( VALUE  x,
VALUE  y 
)

◆ rb_integer_float_eq()

VALUE rb_integer_float_eq ( VALUE  x,
VALUE  y 
)

◆ rb_integer_pack()

int rb_integer_pack ( VALUE  val,
void *  words,
size_t  numwords,
size_t  wordsize,
size_t  nails,
int  flags 
)

◆ rb_integer_unpack()

VALUE rb_integer_unpack ( const void *  words,
size_t  numwords,
size_t  wordsize,
size_t  nails,
int  flags 
)

◆ rb_str2big_karatsuba()

VALUE rb_str2big_karatsuba ( VALUE  arg,
int  base,
int  badcheck 
)

◆ rb_str2big_normal()

VALUE rb_str2big_normal ( VALUE  arg,
int  base,
int  badcheck 
)

◆ rb_str2big_poweroftwo()

VALUE rb_str2big_poweroftwo ( VALUE  arg,
int  base,
int  badcheck 
)

◆ rb_str2inum()

VALUE rb_str2inum ( VALUE  str,
int  base 
)

Definition at line 4494 of file bignum.c.

References rb_str_to_inum().

◆ rb_str_to_inum()

VALUE rb_str_to_inum ( VALUE  str,
int  base,
int  badcheck 
)

◆ rb_uint2big()

VALUE rb_uint2big ( VALUE  n)

◆ rb_uint2inum()

VALUE rb_uint2inum ( VALUE  n)

◆ STATIC_ASSERT() [1/9]

STATIC_ASSERT ( sizeof_bdigit_dbl  ,
sizeof(BDIGIT_DBL = =SIZEOF_BDIGIT_DBL 
)

◆ STATIC_ASSERT() [2/9]

STATIC_ASSERT ( sizeof_bdigit_dbl_signed  ,
sizeof(BDIGIT_DBL_SIGNED = =SIZEOF_BDIGIT_DBL 
)

◆ STATIC_ASSERT() [3/9]

STATIC_ASSERT ( sizeof_bdigit  ,
SIZEOF_BDIGIT<=  sizeofBDIGIT 
)

◆ STATIC_ASSERT() [4/9]

STATIC_ASSERT ( sizeof_bdigit_and_dbl  ,
SIZEOF_BDIGIT *2<=  SIZEOF_BDIGIT_DBL 
)

◆ STATIC_ASSERT() [5/9]

STATIC_ASSERT ( bdigit_signedness  )

◆ STATIC_ASSERT() [6/9]

STATIC_ASSERT ( bdigit_dbl_signedness  )

◆ STATIC_ASSERT() [7/9]

STATIC_ASSERT ( bdigit_dbl_signed_signedness  ,
,
(BDIGIT_DBL_SIGNED) -  1 
)

◆ STATIC_ASSERT() [8/9]

STATIC_ASSERT ( rbignum_embed_len_max  ,
BIGNUM_EMBED_LEN_MAX<=  BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT 
)

◆ STATIC_ASSERT() [9/9]

STATIC_ASSERT ( sizeof_long_and_sizeof_bdigit  ,
SIZEOF_BDIGIT SIZEOF_LONG = =0 
)

◆ str2big_karatsuba()

static VALUE str2big_karatsuba ( int  sign,
const char *  digits_start,
const char *  digits_end,
size_t  num_digits,
size_t  num_bdigits,
int  digits_per_bdigits_dbl,
int  base 
)
static

◆ str2big_normal()

static VALUE str2big_normal ( int  sign,
const char *  digits_start,
const char *  digits_end,
size_t  num_bdigits,
int  base 
)
static

◆ str2big_poweroftwo()

static VALUE str2big_poweroftwo ( int  sign,
const char *  digits_start,
const char *  digits_end,
size_t  num_digits,
int  bits_per_digit 
)
static

Definition at line 3766 of file bignum.c.

References assert, BDIGIT, BDIGIT_DBL, BDIGITS, BIGDN, BIGLO, bignew, BITSPERDIG, conv_digit, dp, and roomof.

Referenced by rb_cstr_parse_inum(), and rb_str2big_poweroftwo().

◆ str2big_scan_digits()

static int str2big_scan_digits ( const char *  s,
const char *  str,
int  base,
int  badcheck,
size_t *  num_digits_p,
ssize_t *  len_p 
)
static

◆ twocomp2abs_bang()

static void twocomp2abs_bang ( VALUE  x,
int  hibits 
)
static

Definition at line 3060 of file bignum.c.

References BIGNUM_SET_SIGN, and get2comp().

Referenced by big_shift3(), bigand_int(), bigor_int(), bigxor_int(), rb_big_and(), rb_big_or(), and rb_big_xor().

◆ valid_radix_p()

static int valid_radix_p ( int  base)
inlinestatic

◆ validate_integer_pack_format()

static void validate_integer_pack_format ( size_t  numwords,
size_t  wordsize,
size_t  nails,
int  flags,
int  supported_flags 
)
static

Variable Documentation

◆ bary_mul_karatsuba_start

mulfunc_t bary_mul_karatsuba_start
static

Definition at line 145 of file bignum.c.

Referenced by bary_mul_karatsuba().

◆ bary_mul_toom3_start

mulfunc_t bary_mul_toom3_start
static

Definition at line 144 of file bignum.c.

Referenced by bary_mul(), and bary_mul_toom3().

◆ base36_numdigits_cache

size_t base36_numdigits_cache[35][MAX_BASE36_POWER_TABLE_ENTRIES]
static

Definition at line 4600 of file bignum.c.

◆ base36_power_cache

VALUE base36_power_cache[35][MAX_BASE36_POWER_TABLE_ENTRIES]
static

Definition at line 4599 of file bignum.c.

◆ ruby_digitmap

const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz"