Ruby: bignum.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
bignum.c File Reference
`#include "ruby/internal/config.h"`
`#include <ctype.h>`
`#include <float.h>`
`#include <math.h>`
`#include "id.h"`
`#include "internal.h"`
`#include "internal/bignum.h"`
`#include "internal/complex.h"`
`#include "internal/gc.h"`
`#include "internal/numeric.h"`
`#include "internal/object.h"`
`#include "internal/sanitizers.h"`
`#include "internal/util.h"`
`#include "internal/variable.h"`
`#include "internal/warnings.h"`
`#include "ruby/thread.h"`
`#include "ruby/util.h"`
`#include "ruby_assert.h"`

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 | 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 | NAIVE_MUL_DIGITS KARATSUBA_MUL_DIGITS
#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 | reinterpret_cast(type, value) (type)value
#define | PUSH_BITS(data, numbits) integer_unpack_push_bits(data, numbits, &dd, &numbits_in_dd, &dp)
#define | BIGNUM_DEBUG (0+RUBY_DEBUG)
#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 | rb_bdigit_dbl_isqrt(x) (BDIGIT)rb_ulong_isqrt(x)
#define | BDIGIT_DBL_TO_DOUBLE(n) (double)(n)
#define | MUL_MODULO(a, b, c) rb_int_modulo(rb_fix_mul_fix((a), (b)), (c))

## 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 }
enum | { DBL_BIGDIG = ((DBL_MANT_DIG + BITSPERDIG) / BITSPERDIG) }

## 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)
VALUE | rb_big_mul_normal (VALUE x, VALUE y)
VALUE | rb_big_sq_fast (VALUE x)
VALUE | rb_big_mul_balance (VALUE x, VALUE y)
VALUE | rb_big_mul_karatsuba (VALUE x, VALUE y)
VALUE | rb_big_mul_toom3 (VALUE x, VALUE y)
VALUE | rb_big_divrem_normal (VALUE x, VALUE y)
int | rb_bigzero_p (VALUE x)
int | rb_cmpint (VALUE val, VALUE a, VALUE b)
void | rb_big_resize (VALUE big, size_t len)
VALUE | rb_big_new (size_t len, int sign)
VALUE | rb_big_clone (VALUE x)
void | rb_big_2comp (VALUE x)
VALUE | rb_big_norm (VALUE x)
VALUE | rb_uint2big (uintptr_t n)
VALUE | rb_int2big (intptr_t n)
VALUE | rb_uint2inum (uintptr_t n)
VALUE | rb_int2inum (intptr_t 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)
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)
VALUE | rb_cstr_to_inum (const char *str, int base, int badcheck)
VALUE | rb_int_parse_cstr (const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags)
VALUE | rb_str_convert_to_inum (VALUE str, int base, int badcheck, int raise_exception)
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)
VALUE | rb_big2str_poweroftwo (VALUE x, int base)
VALUE | rb_big2str_generic (VALUE x, int base)
VALUE | rb_big2str (VALUE x, int base)
unsigned long | rb_big2ulong (VALUE x)
long | rb_big2long (VALUE x)
VALUE | rb_dbl2big (double d)
double | rb_big2dbl (VALUE x)
VALUE | rb_integer_float_cmp (VALUE x, VALUE y)
COMPILER_WARNING_POP VALUE | rb_integer_float_eq (VALUE x, VALUE y)
VALUE | rb_big_cmp (VALUE x, VALUE y)
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)
VALUE | rb_big_plus (VALUE x, VALUE y)
VALUE | rb_big_minus (VALUE x, VALUE y)
VALUE | rb_big_mul (VALUE x, VALUE y)
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)
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)
VALUE | rb_big_and (VALUE x, VALUE y)
VALUE | rb_big_or (VALUE x, VALUE 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)
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)
unsigned long | rb_ulong_isqrt (unsigned long)
VALUE | rb_big_isqrt (VALUE n)
VALUE | rb_int_powm (int const argc, VALUE *const argv, VALUE const num)
void | Init_Bignum (void)

## Variables
const char | ruby_digitmap [] = "0123456789abcdefghijklmnopqrstuvwxyz"

## Macro Definition Documentation

## ◆ ADV

#define ADV | ( |  | n | ) |

Value:
do {\
if (len > 0 && len <= (n)) goto bad; \
str += (n); \
len -= (n); \
} while (0)
len
uint8_t len
Definition: escape.c:17
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18

## ◆ ASSERT_LEN

#define ASSERT_LEN | ( |  | ) |

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

## ◆ BARY_ADD

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

Definition at line 116 of file bignum.c.

## ◆ BARY_ARGS

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

Definition at line 114 of file bignum.c.

## ◆ BARY_DIVMOD

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

Definition at line 119 of file bignum.c.

## ◆ BARY_SHORT_MUL

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

Definition at line 118 of file bignum.c.

## ◆ BARY_SUB

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

Definition at line 117 of file bignum.c.

## ◆ BARY_TRUNC

#define BARY_TRUNC | ( |  | ds,
|  |  | n
| ) |  |

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

Definition at line 136 of file bignum.c.

## ◆ BARY_ZERO_P

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

Definition at line 120 of file bignum.c.

## ◆ BDIGIT_DBL_MAX

#define BDIGIT_DBL_MAX (~(BDIGIT_DBL)0)

Definition at line 94 of file bignum.c.

## ◆ BDIGIT_DBL_TO_DOUBLE

#define BDIGIT_DBL_TO_DOUBLE | ( |  | n | ) | (double)(n)

Definition at line 6855 of file bignum.c.

## ◆ BDIGIT_MSB

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

Definition at line 89 of file bignum.c.

## ◆ bdigit_roomof

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

Definition at line 113 of file bignum.c.

## ◆ BDIGITS

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

Definition at line 85 of file bignum.c.

## ◆ BDIGITS_ZERO

#define BDIGITS_ZERO | ( |  | ptr,
|  |  | n
| ) |  |

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)
BDIGIT
#define BDIGIT
Definition: bigdecimal.h:48
ptr
struct RIMemo * ptr
Definition: debug.c:88

Definition at line 127 of file bignum.c.

## ◆ BDIGMAX

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

Definition at line 93 of file bignum.c.

## ◆ BIGDIVREM_EXTRA_WORDS

#define BIGDIVREM_EXTRA_WORDS 1

Definition at line 112 of file bignum.c.

## ◆ BIGDN

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

Definition at line 91 of file bignum.c.

## ◆ BIGLO

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

Definition at line 92 of file bignum.c.

## ◆ bignew

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

Definition at line 125 of file bignum.c.

## ◆ BIGNUM_DEBUG

#define BIGNUM_DEBUG (0+RUBY_DEBUG)

Definition at line 2914 of file bignum.c.

## ◆ BIGNUM_SET_LEN

#define BIGNUM_SET_LEN | ( |  | b,
|  |  | l
| ) |  |

Value:
(BIGNUM_EMBED_P(b) ? \
(void)(RBASIC(b)->flags = \
(RBASIC(b)->flags & ~BIGNUM_EMBED_LEN_MASK) | \
((l) << BIGNUM_EMBED_LEN_SHIFT)) : \
(void)(RBIGNUM(b)->as.heap.len = (l)))
BIGNUM_EMBED_LEN_SHIFT
#define BIGNUM_EMBED_LEN_SHIFT
Definition: bignum.h:83
RBIGNUM
#define RBIGNUM(obj)
Definition: bignum.h:77
RBASIC
#define RBASIC(obj)
Definition: rbasic.h:34

Definition at line 2951 of file bignum.c.

## ◆ BIGNUM_SET_NEGATIVE_SIGN

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

Definition at line 122 of file bignum.c.

## ◆ BIGNUM_SET_POSITIVE_SIGN

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

Definition at line 123 of file bignum.c.

## ◆ BIGRAD

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

Definition at line 87 of file bignum.c.

## ◆ BIGRAD_HALF

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

Definition at line 88 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) : \
rb_absint_size(x, NULL))
rb_absint_size
size_t rb_absint_size(VALUE val, int *nlz_bits_ret)
Definition: bignum.c:3253
BDIGITS
#define BDIGITS(x)
Definition: bignum.c:85
SIZEOF_BDIGIT
#define SIZEOF_BDIGIT
Definition: bignum.h:25
CHAR_BIT
#define CHAR_BIT
Definition: limits.h:44
NULL
#define NULL
Definition: regenc.h:69

Definition at line 107 of file bignum.c.

## ◆ BIGUP

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

Definition at line 90 of file bignum.c.

## ◆ BIGZEROP

#define BIGZEROP | ( |  | x | ) |

Value:
(BIGNUM_LEN(x) == 0 || \
(BDIGITS(x)[0] == 0 && \
(BIGNUM_LEN(x) == 1 || bigzero_p(x))))

Definition at line 104 of file bignum.c.

## ◆ BITSPERDIG

#define BITSPERDIG (SIZEOF_BDIGIT*CHAR_BIT)

Definition at line 86 of file bignum.c.

## ◆ CLEAR_LOWBITS

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

Definition at line 81 of file bignum.c.

## ◆ conv_digit

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

Definition at line 3710 of file bignum.c.

## ◆ FILL_DD

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

## ◆ FILL_LOWBITS

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

Definition at line 82 of file bignum.c.

## ◆ GMP_BIG2STR_DIGITS

#define GMP_BIG2STR_DIGITS 20

Definition at line 149 of file bignum.c.

## ◆ GMP_DIV_DIGITS

#define GMP_DIV_DIGITS 20

Definition at line 148 of file bignum.c.

## ◆ GMP_MUL_DIGITS

#define GMP_MUL_DIGITS 20

Definition at line 144 of file bignum.c.

## ◆ GMP_STR2BIG_DIGITS

#define GMP_STR2BIG_DIGITS 20

Definition at line 150 of file bignum.c.

## ◆ HOST_BIGENDIAN_P

#define HOST_BIGENDIAN_P 0

Definition at line 76 of file bignum.c.

## ◆ INTEGER_PACK_BYTEORDER_MASK

#define INTEGER_PACK_BYTEORDER_MASK

Value:
(INTEGER_PACK_MSBYTE_FIRST | \
INTEGER_PACK_LSBYTE_FIRST | \
INTEGER_PACK_NATIVE_BYTE_ORDER)
INTEGER_PACK_MSBYTE_FIRST
#define INTEGER_PACK_MSBYTE_FIRST
Definition: bignum.h:82
INTEGER_PACK_LSBYTE_FIRST
#define INTEGER_PACK_LSBYTE_FIRST
Definition: bignum.h:83
INTEGER_PACK_NATIVE_BYTE_ORDER
#define INTEGER_PACK_NATIVE_BYTE_ORDER
Definition: bignum.h:84

Definition at line 502 of file bignum.c.

## ◆ INTEGER_PACK_WORDORDER_MASK

#define INTEGER_PACK_WORDORDER_MASK

Value:
(INTEGER_PACK_MSWORD_FIRST | \
INTEGER_PACK_LSWORD_FIRST)
INTEGER_PACK_MSWORD_FIRST
#define INTEGER_PACK_MSWORD_FIRST
Definition: bignum.h:80
INTEGER_PACK_LSWORD_FIRST
#define INTEGER_PACK_LSWORD_FIRST
Definition: bignum.h:81

Definition at line 499 of file bignum.c.

## ◆ KARATSUBA_BALANCED

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

Definition at line 141 of file bignum.c.

## ◆ KARATSUBA_MUL_DIGITS

#define KARATSUBA_MUL_DIGITS 70

Definition at line 145 of file bignum.c.

## ◆ LSHIFTABLE

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

Definition at line 79 of file bignum.c.

## ◆ LSHIFTX

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

Definition at line 80 of file bignum.c.

## ◆ MAX_BASE36_POWER_TABLE_ENTRIES

#define MAX_BASE36_POWER_TABLE_ENTRIES (SIZEOF_SIZE_T * CHAR_BIT + 1)

Definition at line 4653 of file bignum.c.

## ◆ MUL_MODULO

#define MUL_MODULO | ( |  | a,
|  |  | b,
|  |  | c
| ) |  | rb_int_modulo(rb_fix_mul_fix((a), (b)), (c))

## ◆ NAIVE_MUL_DIGITS

#define NAIVE_MUL_DIGITS KARATSUBA_MUL_DIGITS

Definition at line 154 of file bignum.c.

## ◆ POW2_P

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

Definition at line 83 of file bignum.c.

## ◆ PUSH_BITS

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

## ◆ rb_bdigit_dbl_isqrt

#define rb_bdigit_dbl_isqrt | ( |  | x | ) | (BDIGIT)rb_ulong_isqrt(x)

Definition at line 6852 of file bignum.c.

## ◆ RB_BIGNUM_TYPE_P

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

Definition at line 46 of file bignum.c.

## ◆ reinterpret_cast

#define reinterpret_cast | ( |  | type,
|  |  | value
| ) |  | (type)value

Definition at line 1104 of file bignum.c.

## ◆ SIZEOF_BDIGIT_DBL

#define SIZEOF_BDIGIT_DBL SIZEOF_LONG_LONG

Definition at line 52 of file bignum.c.

## ◆ TAKE_LOWBITS

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

## ◆ TOOM3_BALANCED

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

Definition at line 142 of file bignum.c.

## ◆ TOOM3_MUL_DIGITS

#define TOOM3_MUL_DIGITS 150

Definition at line 146 of file bignum.c.

## ◆ U16

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

Definition at line 183 of file bignum.c.

## ◆ U32

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

Definition at line 184 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 157 of file bignum.c.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
DBL_BIGDIG |

Definition at line 6157 of file bignum.c.

## ◆ big_op_t

enum big_op_t

Enumerator
big_op_gt |
big_op_ge |
big_op_lt |
big_op_le |

Definition at line 5443 of file bignum.c.

## Function Documentation

## ◆ Init_Bignum()

void Init_Bignum | ( | void |  | ) |

Definition at line 7175 of file bignum.c.

References rb_cInteger, rb_cObject, rb_define_const(), rb_define_method, rb_deprecate_constant, and rb_sprintf().

## ◆ rb_absint_numwords()

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

Definition at line 3388 of file bignum.c.

References assert, CHAR_BIT, rb_absint_size(), and SIZE_MAX.

Referenced by rb_big_pow(), and rb_str_format().

## ◆ rb_absint_singlebit_p()

int rb_absint_singlebit_p | ( | VALUE | val | ) |

Definition at line 3452 of file bignum.c.

References BDIGIT, bdigit_roomof, BDIGITS, BIGDN, BIGLO, 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
| ) |  |

Definition at line 3253 of file bignum.c.

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

Referenced by rb_absint_numwords(), rb_big_bit_length(), and rb_num_to_uint().

## ◆ rb_big2dbl()

double rb_big2dbl | ( | VALUE | x | ) |

Definition at line 5309 of file bignum.c.

References HUGE_VAL, isinf(), and rb_warning().

Referenced by ole_val2variant(), rb_big_minus(), rb_big_mul(), rb_big_plus(), rb_big_pow(), rb_float_div(), rb_float_minus(), rb_float_mul(), rb_float_plus(), and rb_float_pow().

## ◆ rb_big2long()

long rb_big2long | ( | VALUE | x | ) |

Definition at line 5139 of file bignum.c.

References long(), LONG_MAX, LONG_MIN, num, rb_eRangeError, and rb_raise().

Referenced by rb_num2long().

## ◆ rb_big2str()

VALUE rb_big2str | ( | VALUE | x,
|  | int | base
| ) |  |

Definition at line 5090 of file bignum.c.

References big2str_struct::base.

Referenced by rb_int2str(), and rb_str_format().

## ◆ rb_big2str_generic()

VALUE rb_big2str_generic | ( | VALUE | x,
|  | int | base
| ) |  |

Definition at line 5004 of file bignum.c.

References big2str_struct::base.

## ◆ rb_big2str_poweroftwo()

VALUE rb_big2str_poweroftwo | ( | VALUE | x,
|  | int | base
| ) |  |

Definition at line 4921 of file bignum.c.

## ◆ rb_big2ulong()

unsigned long rb_big2ulong | ( | VALUE | x | ) |

Definition at line 5124 of file bignum.c.

References long(), LONG_MIN, num, rb_eRangeError, and rb_raise().

Referenced by rb_num_to_uint().

## ◆ rb_big_2comp()

void rb_big_2comp | ( | VALUE | x | ) |

Definition at line 3055 of file bignum.c.

## ◆ rb_big_abs()

VALUE rb_big_abs | ( | VALUE | x | ) |

Definition at line 6759 of file bignum.c.

References BIGNUM_SET_POSITIVE_SIGN, and rb_big_clone().

Referenced by rb_int_abs().

## ◆ rb_big_and()

VALUE rb_big_and | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6357 of file bignum.c.

References BDIGIT, BDIGITS, bignew, FIX2LONG, FIXNUM_P, RB_GC_GUARD, RB_INTEGER_TYPE_P, and rb_num_coerce_bit().

Referenced by rb_int_and().

## ◆ rb_big_aref()

VALUE rb_big_aref | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6678 of file bignum.c.

References BDIGIT, BDIGITS, BIGSIZE, BITSPERDIG, INT2FIX, NUM2LONG, and RB_BIGNUM_TYPE_P.

## ◆ rb_big_bit_length()

VALUE rb_big_bit_length | ( | VALUE | big | ) |

Definition at line 6787 of file bignum.c.

References BARY_ARGS, BARY_SHORT_MUL, BARY_SUB, BDIGIT, bdigit_roomof, CHAR_BIT, INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, LONG2FIX, numberof, rb_absint_singlebit_p(), rb_absint_size(), rb_integer_unpack(), SIZE_MAX, and SIZET2NUM.

Referenced by rb_int_bit_length().

## ◆ rb_big_clone()

VALUE rb_big_clone | ( | VALUE | x | ) |

Definition at line 3026 of file bignum.c.

References BDIGIT, BDIGITS, 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
| ) |  |

Definition at line 5416 of file bignum.c.

References BDIGITS, FIXNUM_P, idCmp, INT2FIX, RB_BIGNUM_TYPE_P, rb_integer_float_cmp(), rb_num_coerce_cmp(), and SIGNED_VALUE.

Referenced by rb_int_cmp(), and rb_integer_float_cmp().

## ◆ rb_big_comp()

VALUE rb_big_comp | ( | VALUE | x | ) |

Definition at line 5561 of file bignum.c.

References BDIGIT, BDIGITS, BIGNUM_SET_NEGATIVE_SIGN, BIGNUM_SET_POSITIVE_SIGN, INT2FIX, and rb_big_clone().

Referenced by rb_int_comp().

## ◆ rb_big_div()

VALUE rb_big_div | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6088 of file bignum.c.

Referenced by rb_int_div().

## ◆ rb_big_divmod()

VALUE rb_big_divmod | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6132 of file bignum.c.

References div, FIX2LONG, FIXNUM_P, mod, rb_assoc_new(), RB_BIGNUM_TYPE_P, rb_int2big(), and rb_num_coerce_bin().

Referenced by rb_int_divmod().

## ◆ rb_big_divrem_normal()

VALUE rb_big_divrem_normal | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 2741 of file bignum.c.

References BARY_TRUNC, BDIGIT, BDIGITS, BIGDIVREM_EXTRA_WORDS, bignew, LONG2FIX, rb_assoc_new(), RB_GC_GUARD, rb_num_zerodiv(), big_div_struct::yds, and big_div_struct::yn.

## ◆ rb_big_eq()

VALUE rb_big_eq | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5521 of file bignum.c.

References BDIGIT, BDIGITS, FIXNUM_P, MEMCMP, Qfalse, Qtrue, RB_BIGNUM_TYPE_P, rb_equal(), and rb_integer_float_eq().

Referenced by rb_int_equal(), and rb_integer_float_eq().

## ◆ rb_big_eql()

VALUE rb_big_eql | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5541 of file bignum.c.

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

## ◆ rb_big_even_p()

VALUE rb_big_even_p | ( | VALUE | num | ) |

Definition at line 6837 of file bignum.c.

References BDIGITS, num, Qfalse, and Qtrue.

## ◆ rb_big_fdiv()

VALUE rb_big_fdiv | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6235 of file bignum.c.

References DBL2NUM, and rb_big_fdiv_double().

## ◆ rb_big_fdiv_double()

double rb_big_fdiv_double | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6206 of file bignum.c.

References DBL2NUM, FIX2LONG, FIXNUM_P, isinf(), isnan, NUM2DBL, RB_BIGNUM_TYPE_P, rb_flo_div_flo(), rb_int2big(), rb_num_coerce_bin(), and RFLOAT_VALUE.

Referenced by rb_big_fdiv(), and rb_int_fdiv_double().

## ◆ rb_big_ge()

VALUE rb_big_ge | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5492 of file bignum.c.

References big_op_ge.

Referenced by rb_int_ge().

## ◆ rb_big_gt()

VALUE rb_big_gt | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5486 of file bignum.c.

References big_op_gt.

Referenced by rb_int_gt().

## ◆ rb_big_hash()

VALUE rb_big_hash | ( | VALUE | x | ) |

Definition at line 6723 of file bignum.c.

References BDIGIT, BDIGITS, rb_memhash(), and ST2FIX.

## ◆ rb_big_idiv()

VALUE rb_big_idiv | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6094 of file bignum.c.

Referenced by rb_int_idiv().

## ◆ rb_big_isqrt()

VALUE rb_big_isqrt | ( | VALUE | n | ) |

Definition at line 6908 of file bignum.c.

References BARY_TRUNC, BDIGIT, BDIGITS, BIGDIVREM_EXTRA_WORDS, len, NULL, rb_bdigit_dbl_isqrt, rb_cInteger, rb_gc_force_recycle(), t, ULL2NUM, and ULONG2NUM.

## ◆ rb_big_le()

VALUE rb_big_le | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5504 of file bignum.c.

References big_op_le.

## ◆ rb_big_lshift()

VALUE rb_big_lshift | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6618 of file bignum.c.

References bit_length, BITSPERDIG, FIX2LONG, FIXNUM_P, int(), long(), RB_BIGNUM_TYPE_P, and rb_to_int().

Referenced by rb_int_lshift().

## ◆ rb_big_lt()

VALUE rb_big_lt | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5498 of file bignum.c.

References big_op_lt.

## ◆ rb_big_minus()

VALUE rb_big_minus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5850 of file bignum.c.

References DBL2NUM, FIX2LONG, FIXNUM_P, rb_big2dbl(), RB_BIGNUM_TYPE_P, rb_num_coerce_bin(), and RFLOAT_VALUE.

Referenced by rb_int_minus().

## ◆ rb_big_modulo()

VALUE rb_big_modulo | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6100 of file bignum.c.

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

Referenced by rb_int_modulo().

## ◆ rb_big_mul()

VALUE rb_big_mul | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5930 of file bignum.c.

References DBL2NUM, FIX2LONG, FIXNUM_P, rb_big2dbl(), RB_BIGNUM_TYPE_P, rb_int2big(), rb_num_coerce_bin(), and RFLOAT_VALUE.

Referenced by rb_int_mul().

## ◆ rb_big_mul_balance()

VALUE rb_big_mul_balance | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1699 of file bignum.c.

References BDIGITS, bignew, NULL, and RB_GC_GUARD.

## ◆ rb_big_mul_karatsuba()

VALUE rb_big_mul_karatsuba | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1880 of file bignum.c.

References BDIGITS, bignew, KARATSUBA_BALANCED, NULL, rb_eArgError, RB_GC_GUARD, and rb_raise().

## ◆ rb_big_mul_normal()

VALUE rb_big_mul_normal | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1571 of file bignum.c.

References BDIGITS, bignew, and RB_GC_GUARD.

## ◆ rb_big_mul_toom3()

VALUE rb_big_mul_toom3 | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 2277 of file bignum.c.

References BDIGITS, bignew, NULL, rb_eArgError, RB_GC_GUARD, rb_raise(), and TOOM3_BALANCED.

## ◆ rb_big_new()

VALUE rb_big_new | ( | size_t | len,
|  | int | sign
| ) |  |

Definition at line 3020 of file bignum.c.

References bignew, and len.

## ◆ rb_big_norm()

VALUE rb_big_norm | ( | VALUE | x | ) |

Definition at line 3158 of file bignum.c.

Referenced by rb_fix_aref().

## ◆ rb_big_odd_p()

VALUE rb_big_odd_p | ( | VALUE | num | ) |

Definition at line 6828 of file bignum.c.

References BDIGITS, num, Qfalse, and Qtrue.

Referenced by rb_int_odd_p().

## ◆ rb_big_or()

VALUE rb_big_or | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6476 of file bignum.c.

References BDIGIT, BDIGITS, bignew, FIX2LONG, FIXNUM_P, RB_GC_GUARD, RB_INTEGER_TYPE_P, and rb_num_coerce_bit().

## ◆ rb_big_pack()

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

Definition at line 3221 of file bignum.c.

References INTEGER_PACK_2COMP, INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, and rb_integer_pack().

## ◆ rb_big_plus()

VALUE rb_big_plus | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5821 of file bignum.c.

References DBL2NUM, FIX2LONG, FIXNUM_P, rb_big2dbl(), RB_BIGNUM_TYPE_P, rb_num_coerce_bin(), and RFLOAT_VALUE.

Referenced by rb_int_plus(), and rb_int_succ().

## ◆ rb_big_pow()

VALUE rb_big_pow | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6241 of file bignum.c.

References BIGZEROP, DBL2NUM, FIX2LONG, FIXNUM_MAX, FIXNUM_P, idPow, INT2FIX, LONG2NUM, mask, NULL, NUM2DBL, rb_absint_numwords(), rb_big2dbl(), rb_big_pow(), RB_BIGNUM_TYPE_P, rb_dbl_complex_new_polar_pi(), RB_INTEGER_TYPE_P, rb_num_coerce_bin(), rb_rational_raw(), rb_warn(), RFLOAT_VALUE, and SIGNED_VALUE.

Referenced by rb_big_pow(), and rb_int_pow().

## ◆ rb_big_remainder()

VALUE rb_big_remainder | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6116 of file bignum.c.

References FIX2LONG, FIXNUM_P, RB_BIGNUM_TYPE_P, rb_int2big(), rb_intern(), and rb_num_coerce_bin().

## ◆ rb_big_resize()

void rb_big_resize | ( | VALUE | big,
|  | size_t | len
| ) |  |

Definition at line 2994 of file bignum.c.

References BIGNUM_SET_LEN, and len.

## ◆ rb_big_rshift()

VALUE rb_big_rshift | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6648 of file bignum.c.

References bit_length, BITSPERDIG, FIX2LONG, FIXNUM_P, int(), long(), RB_BIGNUM_TYPE_P, and rb_to_int().

## ◆ rb_big_sign()

int rb_big_sign | ( | VALUE | x | ) |

Definition at line 6769 of file bignum.c.

## ◆ rb_big_size()

size_t rb_big_size | ( | VALUE | big | ) |

Definition at line 6775 of file bignum.c.

References BIGSIZE.

Referenced by rb_big_size_m().

## ◆ rb_big_size_m()

VALUE rb_big_size_m | ( | VALUE | big | ) |

Definition at line 6781 of file bignum.c.

References rb_big_size(), and SIZET2NUM.

## ◆ rb_big_sq_fast()

VALUE rb_big_sq_fast | ( | VALUE | x | ) |

Definition at line 1640 of file bignum.c.

References BDIGITS, bignew, and RB_GC_GUARD.

## ◆ rb_big_uminus()

VALUE rb_big_uminus | ( | VALUE | x | ) |

Definition at line 5551 of file bignum.c.

References rb_big_clone().

Referenced by rb_int_uminus(), and rb_str_format().

## ◆ rb_big_unpack()

VALUE rb_big_unpack | ( | unsigned long * | buf,
|  | long | num_longs
| ) |  |

Definition at line 3229 of file bignum.c.

References INTEGER_PACK_2COMP, INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, and rb_integer_unpack().

## ◆ rb_big_xor()

VALUE rb_big_xor | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 6570 of file bignum.c.

References BDIGIT, BDIGITS, bignew, FIX2LONG, FIXNUM_P, RB_GC_GUARD, RB_INTEGER_TYPE_P, and rb_num_coerce_bit().

## ◆ rb_bigzero_p()

int rb_bigzero_p | ( | VALUE | x | ) |

Definition at line 2924 of file bignum.c.

References BIGZEROP.

Referenced by rb_int_powm().

## ◆ rb_cmpint()

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

Definition at line 2930 of file bignum.c.

References BIGZEROP, FIX2LONG, FIXNUM_P, INT2FIX, NIL_P, RB_BIGNUM_TYPE_P, rb_cmperr(), rb_funcall(), and RTEST.

## ◆ rb_cstr2inum()

VALUE rb_cstr2inum | ( | const char * | str,
|  | int | base
| ) |  |

Definition at line 4544 of file bignum.c.

References rb_cstr_to_inum(), and str.

## ◆ rb_cstr_to_inum()

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

Definition at line 4016 of file bignum.c.

References INT2FIX, NIL_P, NULL, rb_invalid_str(), and str.

Referenced by rb_cstr2inum().

## ◆ rb_dbl2big()

VALUE rb_dbl2big | ( | double | d | ) |

Definition at line 5248 of file bignum.c.

Referenced by rb_integer_float_cmp(), rb_integer_float_eq(), rb_node_case_when_optimizable_literal(), rb_str_format(), and ruby_num_interval_step_size().

## ◆ rb_int2big()

VALUE rb_int2big | ( | intptr_t | n | ) |

Definition at line 3186 of file bignum.c.

References BIGNUM_SET_NEGATIVE_SIGN, neg, and rb_uint2big().

Referenced by rb_big_divmod(), rb_big_fdiv_double(), rb_big_modulo(), rb_big_mul(), rb_big_remainder(), and rb_int2inum().

## ◆ rb_int2inum()

VALUE rb_int2inum | ( | intptr_t | n | ) |

Definition at line 3214 of file bignum.c.

References FIXABLE, LONG2FIX, and rb_int2big().

## ◆ rb_int_parse_cstr()

VALUE rb_int_parse_cstr | ( | const char * | str,
|  | ssize_t | len,
|  | char ** | endp,
|  | size_t * | ndigits,
|  | int | base,
|  | int | flags
| ) |  |

Definition at line 4045 of file bignum.c.

References ADV, ASSERT_LEN, bit_length, conv_digit, GMP_STR2BIG_DIGITS, INT2FIX, ISSPACE, KARATSUBA_MUL_DIGITS, len, long(), LONG2FIX, NULL, POSFIXABLE, POW2_P, Qnil, RB_INT_PARSE_PREFIX, RB_INT_PARSE_SIGN, RB_INT_PARSE_UNDERSCORE, rb_uint2big(), roomof, ruby_scan_digits(), and str.

## ◆ rb_int_powm()

VALUE rb_int_powm | ( | int const | argc,
|  | VALUE *const | argv,
|  | VALUE const | num
| ) |  |

Definition at line 7108 of file bignum.c.

References argc, argv, FIX2LONG, FIXNUM_P, HALF_LONG_MSB, INT2FIX, long(), num, Qnil, rb_bigzero_p(), rb_check_arity, rb_eRangeError, rb_eTypeError, rb_int_modulo(), rb_int_negative_p(), rb_int_pow(), rb_int_uminus(), RB_INTEGER_TYPE_P, rb_num_zerodiv(), rb_raise(), and UNREACHABLE_RETURN.

Referenced by Init_Numeric().

## ◆ rb_integer_float_cmp()

VALUE rb_integer_float_cmp | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5324 of file bignum.c.

References FIX2LONG, FIXNUM_MAX, FIXNUM_MIN, FIXNUM_P, INT2FIX, isinf(), isnan, long(), Qnil, rb_big_cmp(), rb_dbl2big(), and RFLOAT_VALUE.

Referenced by rb_big_cmp(), and rb_float_gt().

## ◆ rb_integer_float_eq()

COMPILER_WARNING_POP VALUE rb_integer_float_eq | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 5383 of file bignum.c.

References FIX2LONG, FIXNUM_P, isinf(), isnan, long(), LONG_MIN, Qfalse, Qtrue, rb_big_eq(), rb_dbl2big(), and RFLOAT_VALUE.

Referenced by rb_big_eq(), and rb_float_equal().

## ◆ rb_integer_pack()

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

Definition at line 3553 of file bignum.c.

References BDIGIT, bdigit_roomof, BDIGITS, BIGDN, BIGLO, FIX2LONG, FIXNUM_P, numberof, RB_GC_GUARD, and rb_to_int().

Referenced by rb_big_pack(), rb_hash(), and rb_str_format().

## ◆ rb_integer_unpack()

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

Definition at line 3639 of file bignum.c.

References BDIGIT, BDIGIT_DBL, BDIGIT_DBL_SIGNED, BDIGIT_MSB, BDIGITS, bignew, BIGUP, INTEGER_PACK_2COMP, INTEGER_PACK_FORCE_BIGNUM, INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION, INTEGER_PACK_LSBYTE_FIRST, INTEGER_PACK_LSWORD_FIRST, INTEGER_PACK_MSBYTE_FIRST, INTEGER_PACK_MSWORD_FIRST, INTEGER_PACK_NATIVE_BYTE_ORDER, INTEGER_PACK_NEGATIVE, LONG2FIX, LONG_MAX, MEMCPY, NEGFIXABLE, numberof, POSFIXABLE, Qfalse, rb_eArgError, and rb_raise().

Referenced by rb_big_bit_length(), and rb_big_unpack().

## ◆ rb_str2big_karatsuba()

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

Definition at line 4358 of file bignum.c.

References len, RB_GC_GUARD, rb_must_asciicompat(), roomof, RSTRING_LEN, str, and StringValuePtr.

## ◆ rb_str2big_normal()

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

Definition at line 4316 of file bignum.c.

References len, RB_GC_GUARD, rb_must_asciicompat(), roomof, RSTRING_LEN, str, and StringValuePtr.

## ◆ rb_str2big_poweroftwo()

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

Definition at line 4280 of file bignum.c.

References bit_length, len, POW2_P, RB_GC_GUARD, rb_must_asciicompat(), RSTRING_LEN, str, and StringValueCStr.

## ◆ rb_str2inum()

VALUE rb_str2inum | ( | VALUE | str,
|  | int | base
| ) |  |

Definition at line 4550 of file bignum.c.

References rb_str_to_inum(), and str.

## ◆ rb_str_convert_to_inum()

VALUE rb_str_convert_to_inum | ( | VALUE | str,
|  | int | base,
|  | int | badcheck,
|  | int | raise_exception
| ) |  |

Definition at line 4252 of file bignum.c.

References INT2FIX, len, NIL_P, NULL, Qnil, rb_must_asciicompat(), RSTRING_GETMEM, str, and StringValue.

Referenced by rb_str_to_inum().

## ◆ rb_str_to_inum()

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

Definition at line 4274 of file bignum.c.

References rb_str_convert_to_inum(), str, and TRUE.

Referenced by rb_str2inum(), rb_str_format(), rb_str_upto_each(), and rb_str_upto_endless_each().

## ◆ rb_uint2big()

VALUE rb_uint2big | ( | uintptr_t | n | ) |

Definition at line 3164 of file bignum.c.

References BDIGIT, bdigit_roomof, BDIGITS, BIGDN, BIGLO, bignew, BIGNUM_SET_LEN, and SIZEOF_VALUE.

Referenced by rb_int2big(), rb_int_parse_cstr(), and rb_uint2inum().

## ◆ rb_uint2inum()

VALUE rb_uint2inum | ( | uintptr_t | n | ) |

Definition at line 3207 of file bignum.c.

References LONG2FIX, POSFIXABLE, and rb_uint2big().

## ◆ rb_ulong_isqrt()

unsigned long rb_ulong_isqrt | ( | unsigned long |  | ) |

## ◆ STATIC_ASSERT() [1/9]

STATIC_ASSERT | ( | bdigit_dbl_signed_signedness | ,
|  | 0 | ,
|  | (BDIGIT_DBL_SIGNED) - | 1
| ) |  |

## ◆ STATIC_ASSERT() [2/9]

STATIC_ASSERT | ( | bdigit_dbl_signedness |  | ) |

## ◆ STATIC_ASSERT() [3/9]

STATIC_ASSERT | ( | bdigit_signedness |  | ) |

## ◆ STATIC_ASSERT() [4/9]

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

## ◆ STATIC_ASSERT() [5/9]

STATIC_ASSERT | ( | sizeof_bdigit | ,
|  | SIZEOF_BDIGIT<= | sizeofBDIGIT
| ) |  |

## ◆ STATIC_ASSERT() [6/9]

STATIC_ASSERT | ( | sizeof_bdigit_and_dbl | ,
|  | SIZEOF_BDIGIT *2<= | SIZEOF_BDIGIT_DBL
| ) |  |

## ◆ STATIC_ASSERT() [7/9]

STATIC_ASSERT | ( | sizeof_bdigit_dbl | ,
|  | sizeof(BDIGIT_DBL) | = `=SIZEOF_BDIGIT_DBL`
| ) |  |

## ◆ STATIC_ASSERT() [8/9]

STATIC_ASSERT | ( | sizeof_bdigit_dbl_signed | ,
|  | sizeof(BDIGIT_DBL_SIGNED) | = `=SIZEOF_BDIGIT_DBL`
| ) |  |

## ◆ STATIC_ASSERT() [9/9]

STATIC_ASSERT | ( | sizeof_long_and_sizeof_bdigit | ,
|  | SIZEOF_BDIGIT % | SIZEOF_LONG = `=0`
| ) |  |

## Variable Documentation

## ◆ ruby_digitmap

const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz"

Definition at line 48 of file bignum.c.

Referenced by rb_fix2str(), and rb_str_format().