aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
Commit message (Collapse)AuthorAgeFilesLines
...
* bignum.c, math.c: type predicatesnobu2013-09-071-133/+91
| | | | | | * bignum.c, math.c: use type predicate macros instead of TYPE(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: split rb_big_fdiv and big_fdivnobu2013-09-071-23/+25
| | | | | | * bignum.c (rb_big_fdiv): split with big_fdiv by divider type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (GMP_DIV_DIGITS): New macro.akr2013-09-041-3/+98
| | | | | | | | | | | | | | (bary_divmod_gmp): New function. (rb_big_divrem_gmp): Ditto. (bary_divmod_branch): Ditto. (bary_divmod): Use bary_divmod_branch. (bigdivrem): Ditto. * internal.h (rb_big_divrem_gmp): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_divmod_normal): Reduce temporary array allocations.akr2013-09-041-15/+14
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_divrem_normal): Add GC guards.akr2013-09-041-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_divrem_normal): New function.akr2013-09-041-0/+32
| | | | | | | | | | | | * internal.h (rb_big_divrem_normal): Declared. * ext/-test-/bignum/div.c: New file. * test/-ext-/bignum/test_div.rb: New file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem_normal): Removed.akr2013-09-041-76/+81
| | | | | | | | | | (bary_divmod_normal): New function. (bary_divmod): Use bary_divmod_normal. (bigdivrem): Use bary_divmod_normal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem): Useless declaration removed.akr2013-09-041-3/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem_normal): Add assertions.akr2013-09-041-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (GMP_STR2BIG_DIGITS): New macro.akr2013-09-031-0/+92
| | | | | | | | | | | | (str2big_gmp): New function. (rb_cstr_to_inum): Use str2big_gmp for big bignums. (rb_str2big_gmp): New function. * internal.h (rb_str2big_gmp): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_str2big_poweroftwo): New function.akr2013-09-031-0/+111
| | | | | | | | | | | | | | | | | | | (rb_str2big_normal): Ditto. (rb_str2big_karatsuba): Ditto. * internal.h (rb_str2big_poweroftwo): Declared. (rb_str2big_normal): Ditto. (rb_str2big_karatsuba): Ditto. * ext/-test-/bignum/str2big.c: New file. * test/-ext-/bignum/test_str2big.rb: New file. * ext/-test-/bignum/depend: Add the dependency for str2big.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (str2big_scan_digits): Extracted from rb_cstr_to_inum.akr2013-09-031-32/+51
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bytes_2comp): Define it only for little endianakr2013-09-021-0/+2
| | | | | | | | environment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (ISDIGIT): Unused macro removed.akr2013-09-021-3/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (str2big_poweroftwo): Extracted from rb_cstr_to_inum.akr2013-09-021-117/+178
| | | | | | | | | (str2big_normal): Ditto. (str2big_karatsuba): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (Init_Bignum): Define Bignum::GMP_VERSION when GMP is used.akr2013-09-011-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big2str_generic): Reduce arguments.akr2013-09-011-30/+36
| | | | | | | | | (big2str_gmp): Ditto. (rb_big2str1): Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (GMP_BIG2STR_DIGITS): New constant.akr2013-09-011-0/+55
| | | | | | | | | | | | | (big2str_gmp): New function. (rb_big2str1): Use big2str_gmp for big bignums. * internal.h (rb_big2str_gmp): Declared. * ext/-test-/bignum/big2str.c (big2str_gmp): New method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mul_gmp): Use mpz_init and mpz_clear instead ofakr2013-09-011-2/+6
| | | | | | | | | mpz_inits and mpz_clears. Older GMP don't have them. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big2str_base_poweroftwo): Renamed fromakr2013-09-011-28/+54
| | | | | | | | | | | | | | | | | | big2str_base_powerof2. (rb_big2str_poweroftwo): New function for test. (big2str_generic): Extracted from rb_big2str1. (rb_big2str_generic): New function for test. * internal.h (rb_big2str_poweroftwo): Declared. (rb_big2str_generic): Ditto. * ext/-test-/bignum/big2str.c: New file. * test/-ext-/bignum/test_big2str.rb: New file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big2str_2bdigits): Renamed from big2str_orig.akr2013-09-011-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c: Remove BITSPERDIG >= INT_MAX test. The static assertion,akr2013-09-011-4/+1
| | | | | | | SIZEOF_BDIGITS <= sizeof(BDIGIT) is enough. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (maxpow_in_bdigit): Removed.akr2013-09-011-37/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_fix_bit_length): Moved from bignum.c.akr2013-09-011-41/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC]akr2013-09-011-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (bit_length): Moved from bignum.c.akr2013-09-011-126/+0
| | | | | | | | | | | (nlz_int): Ditto. (nlz_long): Ditto. (nlz_long_long): Ditto. (nlz_int128): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bit_length): Renamed from bitsize.akr2013-08-311-11/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_bit_length): New method.akr2013-08-311-0/+110
| | | | | | | | | (rb_fix_bit_length): Ditto. [ruby-core:56247] [Feature #8700] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c: Use GMP to accelerate big Bignum multiplication.akr2013-08-311-2/+60
| | | | | | | | | | | | (bary_mul_gmp): New function. (bary_mul): Use bary_mul_gmp. (bigsq): Use different threshold with GMP. * configure.in: Detect GMP. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (BARY_SHORT_MUL): Renamed from BARY_MUL1.akr2013-08-241-7/+7
| | | | | | | | (bary_short_mul): Renamed from bary_mul1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big2str1): Make an expression more explicit.akr2013-08-181-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big2str1): Use power_level instead of bitsize(xn).akr2013-08-171-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (BIGDIVREM_EXTRA_WORDS): Redefine to 1.akr2013-08-171-21/+7
| | | | | | | | | | (bigdivrem_num_extra_words): Removed. (bigdivrem_normal): Simplefied. (big2str_karatsuba): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem_single1): Renamed from bigdivrem_single. Addakr2013-08-161-7/+13
| | | | | | | | | | x_higher_bdigit argument. (bigdivrem_single): Just call bigdivrem_single1. (bigdivrem_restoring): Use bigdivrem_single1 to avoid memmove. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_small_rshift): Specify the higher BDIGIT instead ofakr2013-08-161-5/+3
| | | | | | | | | sign bit. (big_shift3): Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mul_toom3): Reduce a branch.akr2013-08-151-8/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem_single): Use shift when y is a power of two.akr2013-08-151-9/+18
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem_restoring): Use bigdivrem_single if non-topmostakr2013-08-151-0/+10
| | | | | | | | BDIGITs of y are zero. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big2str1): Truncate topmost zeros of x.akr2013-08-151-14/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_divmod): Simplify an expression.akr2013-08-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem_normal): Remove a local variable.akr2013-08-151-3/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big2str_karatsuba): Use bigdivrem_restoring directly toakr2013-08-151-18/+52
| | | | | | | | | reduce working buffer and memory copy. (rb_big2str1): Allocate working buffer for big2str_karatsuba here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem_restoring): xn argument removed.akr2013-08-131-3/+3
| | | | | | | | (bigdivrem_normal): Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_div_struct): Remove xn and j field. Add zn field. akr2013-08-131-13/+12
| | | | | | | | | (bigdivrem1): Follow the above change. (bigdivrem_restoring): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_div_struct): ynzero field removed.akr2013-08-131-13/+13
| | | | | | | | | (bigdivrem1): Follow the above change. (bigdivrem_restoring): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.akr2013-08-131-14/+23
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bitsize): Fix a conditional expression.akr2013-08-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_div_struct): Use size_t.akr2013-08-091-11/+11
| | | | | | | | | | | | (bigdivrem1): Ditto. (bigdivrem_num_extra_words): Ditto. (bigdivrem_single): Ditto. (bigdivrem_normal): Ditto. (bary_divmod): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: suppress warningnobu2013-08-091-1/+1
| | | | | | | * bignum.c (rb_big_mul_karatsuba): suppress logical-op-parentheses warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_odd_p): Check the bignum length.akr2013-08-071-2/+2
| | | | | | | | (rb_big_even_p): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e