summaryrefslogtreecommitdiff
path: root/bignum.c
AgeCommit message (Collapse)Author
2013-07-09* bignum.c (bary_mul): x*1 is x.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09* bignum.c (bary_mul_single): Invoke MEMZERO here.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09* bignum.c (bary_mul1): No need to invoke MEMZERO at last.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (biglsh_bang): Don't shift a BDIGIT with BITSPERDIG bits.akr
(bigrsh_bang): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (bigrsh_bang): Fix bignum digits overrun.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (biglsh_bang): Fix bignum digits under-run.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (bary_mul): Arguments for work memory added.akr
(bary_mul_balance): Ditto. (bary_mul_karatsuba): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (rb_big_sq_fast): New function for testing.akr
(rb_big_mul_toom3): Ditto. * internal.h (rb_big_sq_fast): Declared. (rb_big_mul_toom3): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (bary_mul_balance): Initialize a local variable to suppressakr
a warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08* bignum.c (bary_mul_balance): Reduce work memory.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c (bary_mul): Add a RB_GC_GUARD.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c (bary_mul_karatsuba): Unreachable code removed. Removeakr
several branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* internal.h (rb_big_mul_normal): Declared.akr
(rb_big_mul_balance): Ditto. (rb_big_mul_karatsuba): Ditto. * bignum.c (rb_big_mul_normal): New function for tests. (rb_big_mul_balance): Ditto. (rb_big_mul_karatsuba): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07Useless comment removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c: Reorder functions to decrease forward reference.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07* bignum.c: (bigsub_core): Use bary_sub.akr
(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
2013-07-07* bignum.c (bary_sq_fast): Extracted from bigsqr_fast andakr
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
2013-07-04* bignum.c (BARY_MUL1): Renamed from BARY_MUL.akr
(bary_mul1): Renamed from bary_mul. (bary_mul): Renamed from bary_mul2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04* bignum.c (bary_mul_balance): Extracted from bigmul1_balance andakr
use bary_mul2 and bary_add to decrease allocations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04bignum.c: constifynobu
* bignum.c: constify maxpow tables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04* bignum.c (maxpow_in_bdigit_dbl): Use tables if available.akr
(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
2013-07-04* bignum.c (rb_cstr_to_inum): Avoid temporary buffer allocation exceptakr
very big base non-power-of-2 numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-03* internal.h (ruby_digit36_to_number_table): Declared.akr
* util.c (ruby_digit36_to_number_table): Moved from scan_digits. * bignum.c (conv_digit): Use ruby_digit36_to_number_table. * pack.c (hex2num): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-03* bignum.c (maxpow_in_bdigit): Renamed from calc_hbase and returnakr
maxpow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02* bignum.c (roomof): Cast to long.akr
(rb_ull2big): Fix bignew arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02* bignum.c (rb_cstr_to_inum): fix 64 bit to 32 bit shorten warningcharliesome
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02* bignum.c (rb_cstr_to_inum): Merge two temporary buffers.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02* bignum.c (rb_cstr_to_inum): Use BDIGIT_DBL to collect adjacent digits.akr
(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
2013-07-01* bignum.c (bary_mul2): New function.akr
(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
2013-07-01* bignum.c (rb_cstr_to_inum): Skip leading zeros.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-30* bignum.c (nlz16): New function.akr
(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
2013-06-30* bignum.c (rb_cstr_to_inum): Use rb_integer_unpack if base is a powerakr
of 2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (big_rshift): Use abs2twocomp and twocomp2abs_bang.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (RBIGNUM_SET_NEGATIVE_SIGN): New macro.akr
(RBIGNUM_SET_POSITIVE_SIGN): Ditto. (rb_big_neg): Inline get2comp to avoid double negation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (bary_neg): Extracted from bary_2comp.akr
(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
2013-06-29* bignum.c (bary_2comp): Simplified.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (bigor_int): Return -1 if y == -1.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (bigor_int): Use RB_GC_GUARD.akr
(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
2013-06-28* bignum.c (bigand_int): Don't apply bitwise and for BDIGIT and long.akr
(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
2013-06-28* bignum.c (rb_big_and): Allocate new bignum with same size to shorterakr
argument if it's high bits are zero. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27* bignum.c (bigand_int): Add arguments, xn and hibitsx.akr
Use twocomp2abs_bang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27* bignum.c (abs2twocomp_bang): Removed.akr
(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
2013-06-27* bignum.c (get2comp): Use bary_2comp.akr
(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
2013-06-26* bignum.c (rb_big_pow): Retry if y is a Bignum and it isakr
representable as a Fixnum. Use rb_absint_numwords. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26* bignum.c (LSHIFTABLE): extract from LSHIFTX().nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26* bignum.c (bigxor_int): Fix a buffer over read.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26* bignum.c (bigand_int): Consider negative values.akr
(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
2013-06-25* bignum.c (bigand_int): Fix a buffer over read.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (bigadd_int): Fix a buffer over read.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (bigsub_int): Fix a buffer over read.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e