(bary_sub): Returns a borrow flag. Use bary_subb.
(bary_subb): New function for actually calculating subtraction with
borrow.
(bary_sub_one): New function.
(bigadd_core): Use bary_add.
(bary_add): Returns a carry flag. Use bary_addc.
(bary_addc): New function for actually calculating addition with
carry.
(bary_add_one): New function.
(bary_muladd_1xN): Extracted from bary_mul_normal.
(bigmul1_normal): Removed.
(bary_mul_karatsuba): New function.
(bary_mul1): Invoke rb_thread_check_ints after bary_mul_normal.
(bary_mul): Remove most and least significant zeros before actual
multiplication. Use bary_sq_fast, bary_mul_balance,
bary_mul_karatsuba and bigmul1_toom3 as bigmul0.
(bigmul1_balance): Removed.
(bigmul1_karatsuba): Removed.
(bigsqr_fast): Removed.
(bary_sparse_p): Extracted from big_sparse_p.
(big_sparse_p): Removed.
(bigmul0): Use bary_mul.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
ensure not to access zds[2*xn].
(bigsqr_fast): Allocate the result bignum with 2*xn words.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(maxpow_in_bdigit): Ditto.
(U16): New macro.
(U32): Ditto.
(U64): Ditto.
(U128): Ditto.
(maxpow16_exp): New table.
(maxpow16_num): New table.
(maxpow32_exp): New table.
(maxpow32_num): New table.
(maxpow64_exp): New table.
(maxpow64_num): New table.
(maxpow128_exp): New table.
(maxpow128_num): New table.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(BDIGIT_DBL_MAX): New macro.
(maxpow_in_bdigit_dbl): New function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_cstr_to_inum): Use a better algorithm to compose the result
if input length is very long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(nlz32): Ditto.
(nlz64): Ditto.
(nlz128): Ditto.
(nlz): Redefined using an above function.
(bitsize): New macro.
(rb_cstr_to_inum): Use bitsize instead of nlz.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_plus_one): Extracted from bary_2comp.
(bary_2comp): Use bary_neg and bary_plus_one.
(big_extend_carry): Extracted from get2comp.
(get2comp): Use big_extend_carry.
(rb_integer_unpack): Use big_extend_carry.
(rb_big_neg): Use bary_neg.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigxor_int): Take xn and hibitsx arguments. Use twocomp2abs_bang.
(rb_big_xor): Use abs2twocomp and twocomp2abs_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigor_int): Take xn and hibitsx arguments. Use twocomp2abs_bang.
(rb_big_or): Use abs2twocomp and twocomp2abs_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(abs2twocomp): Take n_ret argument to return actual length.
(rb_big_and): Follow above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(abs2twocomp_bang): New function.
(abs2twocomp): New function.
(twocomp2abs_bang): New function.
(rb_big_and): Use abs2twocomp and twocomp2abs_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigor_int): The allocated bignum should have enough size
to store long.
This fixes (bignum fits in a BDIGIT) | (fixnum bigger than BDIGIT)
on platforms which SIZEOF_BDIGITS < SIZEOF_LONG,
such as LP64 with 32bit BDIGIT (no int128).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_big_aref): Call big2ulong with TRUE for "check" argument.
It should be non-effective.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
"-u" to suppress warning (C4146) by Visual Studio.
Reported by ko1 via IRC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e