aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
Commit message (Collapse)AuthorAgeFilesLines
* {Fixnum,Bignum}#[] is unified into Integer.akr2016-04-271-21/+1
| | | | | | | | | | | | | * numeric.c (int_aref): {Fixnum,Bignum}#[] is unified into Integer. * bignum.c (rb_big_aref): Don't define Bignum#<<. * internal.h (rb_big_aref): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] update Integer#<< doc.akr2016-04-261-7/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* {Fixnum,Bignum}#<< is unified into Integer.akr2016-04-261-1/+0
| | | | | | | | | | | | | * numeric.c (rb_int_lshift): {Fixnum,Bignum}#<< is unified into Integer. * bignum.c (rb_big_lshift): Don't define Bignum#<<. * internal.h (rb_big_lshift): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* {Fixnum,Bignum}#>> is unified into Integer.akr2016-04-261-9/+0
| | | | | | | | | | | | | * numeric.c (rb_int_rshift): {Fixnum,Bignum}#>> is unified into Integer. * bignum.c (rb_big_rshift): Don't define Bignum#>>. * internal.h (rb_big_rshift): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* {Fixnum,Bignum}#size is unified into Integer.akr2016-04-261-14/+1
| | | | | | | | | | | | * numeric.c (int_size): {Fixnum,Bignum}#size is unified into Integer. * bignum.c (rb_big_size_m): Don't define Bignum#size. * internal.h (rb_big_size_m): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* forgot to remove Bignum#bit_length.akr2016-04-261-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* {Fixnum,Bignum}#bit_length is unified into Integer.akr2016-04-261-39/+1
| | | | | | | | | | | | | | | | | | | * numeric.c (rb_int_bit_length): {Fixnum,Bignum}#bit_length is unified into Integer. * bignum.c (rb_big_bit_length): Don't define Bignum#bit_length. * internal.h (rb_big_bit_length): Declared. --This iine, and those below, will be ignored-- M ChangeLog M bignum.c M internal.h M numeric.c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_abs): Integer#{abs,magnitude} moved from Fixnum and Bignum.akr2016-04-261-13/+1
| | | | | | | | | | * internal.h (rb_big_abs): Declared. * bignum.c (rb_big_abs): Don't define Bignum#{abs,magnitude}. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: int_round_zero_pnobu2016-04-131-3/+9
| | | | | | | | | | * bignum.c (rb_big_size): add wrapper function of BIGSIZE and rename the method funtion with _m suffix. * numeric.c (int_round_zero_p): extracted from rb_int_round. optimize for Bignum, and convert VALUE returned by Numeric#size to long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: rb_cstr_parse_inumnobu2016-04-081-91/+154
| | | | | | | | | | | | * bignum.c (rb_cstr_parse_inum): [EXPERIMENTAL] new function to parse integer in C-string with length. the name and the arguments may be changed in the future. * bignum.c (rb_str_to_inum): preserve encoding of the argument in error messages, and no longer needs to copy non-terminated strings. * bignum.c (rb_str2big_{poweroftwo,normal,karatsuba,gmp}): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: radix check functionsnobu2016-04-081-14/+28
| | | | | | | * bignum.c (valid_radix_p, invalid_radix): extracted functions to check radix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: micro optimizationnobu2016-03-201-2/+5
| | | | | | | * bignum.c (rb_big_cmp): micro optimization of Fixnum comparison. as SIGNED_VALUE and Fixnum have same sign-bits and same order. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_cmp): reduce the code.naruse2016-03-191-20/+8
| | | | | | | * bignum.c (rb_big_eq): If normalized bignum is still bignum, it must be larger than fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (Bignum#<=>): remove it because they are unified withmrkn2016-03-191-1/+0
| | | | | | | | | | | | | | Integer#<=>. * numeric.c (Integer#<=>, Fixnum#<=>): move <=> method from Fixnum to Integer. * numeric.c (int_cmp): add this method for Integer#<=>. * test/-ext-/integer/test_my_integer.rb (test_my_integer_cmp): add a test to examine Integer#<=> for unknown subclasses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_to_f, Bignum#to_f): removed them because they aremrkn2016-03-181-16/+0
| | | | | | | | unified with int_to_f and Integer#to_f. * numeric.c (int_to_f): treat Bignum values directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (Bignum#eql?): remove its definition because it is unifiedmrkn2016-03-181-12/+0
| | | | | | | | with Numeric#eql?. * numeric.c (num_eql): treat Bignum values directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_to_s, Bignum#to_s): remove its definition becausemrkn2016-03-181-31/+0
| | | | | | | | it is unified with Integer#to_s. * numeric.c (int_to_s): treat Bignum values directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_hash): make it public function to be available inmrkn2016-03-181-11/+1
| | | | | | | | | | | | | other source files, and remove documentation comment for Bignum#hash. * bignum.c (Bignum#hash): remove its definition because it is unified with Object#hash. * include/ruby/intern.h (rb_big_hash): add a prototype declaration. * hash.c (any_hash): treat Bignum values directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (Bignum#even?, Bignum#odd?): remove definitionsmrkn2016-03-171-2/+0
| | | | | | | | | | | | | | | | because they are unified with Integer#even? and Integer#odd?. * numeric.c (Fixnum#zero?, Fixnum#even?, Fixnum#odd?): remove definitions because they are unified with Numeric#zero?, Integer#even?, and Integer#odd?. * numeric.c (num_zero_p, int_even_p, int_odd_p): treat Fixnum and Bignum values directly. * test/ruby/test_integer.rb (test_odd_p_even_p): remove meaningless test case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_even_p, rb_big_odd_p): make them public functionsmrkn2016-03-171-2/+2
| | | | | | | | | to be available in other source files. * include/ruby/intern.h (rb_big_even_p, rb_big_odd_p): add prototype declarations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big2str_2bdigits): reduce div instruction.naruse2016-03-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the code so that C compiler unify div instructions of `%` and `/`. Before: 4291b0: 48 89 f0 mov %rsi,%rax 4291b3: 31 d2 xor %edx,%edx 4291b5: 48 83 ef 01 sub $0x1,%rdi 4291b9: 48 f7 f1 div %rcx # <---- ! 4291bc: 41 0f b6 04 11 movzbl (%r9,%rdx,1),%eax 4291c1: 31 d2 xor %edx,%edx 4291c3: 41 88 04 38 mov %al,(%r8,%rdi,1) 4291c7: 48 63 4b 04 movslq 0x4(%rbx),%rcx 4291cb: 48 89 f0 mov %rsi,%rax 4291ce: 48 f7 f1 div %rcx # <---- ! 4291d1: 48 89 c6 mov %rax,%rsi 4291d4: 48 85 ff test %rdi,%rdi 4291d7: 75 d7 jne 4291b0 <big2str_2bdigits+0x50> 4291d9: 48 63 6b 10 movslq 0x10(%rbx),%rbp 4291dd: 48 01 6b 20 add %rbp,0x20(%rbx) 4291e1: 48 8b 44 24 48 mov 0x48(%rsp),%rax 4291e6: 64 48 33 04 25 28 00 xor %fs:0x28,%rax After: 4291b0: 48 63 73 04 movslq 0x4(%rbx),%rsi 4291b4: 31 d2 xor %edx,%edx 4291b6: 48 83 e9 01 sub $0x1,%rcx 4291ba: 48 f7 f6 div %rsi # <---- ! 4291bd: 41 0f b6 14 10 movzbl (%r8,%rdx,1),%edx 4291c2: 88 14 0f mov %dl,(%rdi,%rcx,1) 4291c5: 48 85 c9 test %rcx,%rcx 4291c8: 75 e6 jne 4291b0 <big2str_2bdigits+0x50> 4291ca: 48 63 6b 10 movslq 0x10(%rbx),%rbp 4291ce: 48 01 6b 20 add %rbp,0x20(%rbx) 4291d2: 48 8b 44 24 48 mov 0x48(%rsp),%rax 4291d7: 64 48 33 04 25 28 00 xor %fs:0x28,%rax git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: micro optimizationnobu2016-02-151-3/+3
| | | | | | | | * bignum.c (rb_big_uminus, bigsub_int): use BIGNUM_NEGATE. * internal.h (BIGNUM_NEGATE): simplify negation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use particlar macrosnobu2016-02-151-9/+9
| | | | | | * bignum.c: use particlar macros for positive/negative conditions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * insns.def (opt_mult): Use int128_t for overflow detection.naruse2016-02-051-0/+40
| | | | | | | | | | | * bignum.c (rb_uint128t2big): added for opt_mult. * bignum.c (rb_uint128t2big): added for rb_uint128t2big.. * configure.in: define int128_t, uint128_t and related MACROs. Initially introduced by r41379 but reverted by r50749. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RUBY_ASSERTnobu2016-01-221-1/+1
| | | | | | | * error.c (rb_assert_failure): assertion with stack dump. * ruby_assert.h (RUBY_ASSERT): new header for the assertion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make local symbols staticnobu2015-12-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* preserve encodings in error messagesnobu2015-09-281-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: roomofnobu2015-06-211-1/+0
| | | | | | | * internal.h (roomof): extract from type_roomof, and move from bignum.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: doc of rb_cstr_to_inumnobu2015-06-171-0/+16
| | | | | | * bignum.c (rb_cstr_to_inum): [DOC] add document of the function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * doc/contributors.rdoc: fix a typo. Patch by @davydovantonhsbt2015-04-151-1/+1
| | | | | | | | | | [fix GH-872][ci skip] * doc/syntax/methods.rdoc: ditto. * ext/digest/sha2/sha2.c: ditto. * ext/socket/ipsocket.c: ditto. * ext/tk/*: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-2/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mul_balance_with_mulfunc): Fix free work areaakr2014-11-011-1/+1
| | | | | | | | | | | location. [ruby-dev:48723] [Bug #10464] [ruby-core:66044] [Bug #10465] Reported by Kohji Nishihama. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (absint_numwords_generic): set an array element afterngoto2014-10-091-1/+3
| | | | | | | | | definition of a variable to fix compile error with older version of fcc (Fujitsu C Compiler) 5.6 on Solaris 10 on Sparc. [Bug #10350] [ruby-dev:48608] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add some documents [ci skip]nobu2014-07-281-0/+1
| | | | | | | | | | | | | | | * bignum.c (Init_Bignum): [DOC] Bignum::GMP_VERSION. * complex.c (Init_Complex): [DOC] ignore an internal class. * dir.c (Init_Dir): [DOC] File::FNM_SYSCASE. * file.c (rb_file_exists_p): [DOC] File.exists? is deprecated. * object.c (rb_mod_initialize_clone): [DOC] ignore implementation detail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (struct RBignum): Use size_t for len.akr2014-04-191-17/+22
| | | | | | | | | | | | | | | | * include/ruby/intern.h (rb_big_new): Use size_t instead of long to specify the size of bignum. (rb_big_resize): Ditto. * bignum.c: Follow above changes. * rational.c: Follow above changes. * marshal.c: Follow above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_num2long): Returns a long.akr2014-04-181-2/+2
| | | | | | | | | | | | | | | | | (rb_num2ulong): Returns a unsigned long. * bignum.c (rb_big2long): Returns a long. (rb_big2ulong): Returns a unsigned long. * include/ruby/intern.h: Follow above changes. * include/ruby/ruby.h: Follow above changes. (rb_num2long_inline): No need to cast. (rb_num2ulong_inline): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (SIZEOF_BDIGIT): Renamed from SIZEOF_BDIGITS.akr2014-04-131-77/+77
| | | | | | | | | | | | * internal.h: Ditto. * marshal.c: Ditto. * rational.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: adjust condtionsnobu2014-03-141-7/+4
| | | | | | | * bignum.c (maxpow{16,32,64,128}_{exp,num}): adjust preprocessor condtions to maxpow_in_bdigit_dbl(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] add links to `Object#hash`nobu2014-03-141-0/+2
| | | | | | | add links to `Object#hash` to each #`hash` methods rdocs. [Fixes GH-567] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* adjust indent and stylenobu2014-02-271-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mul_precheck): fix a copy-paste error.mame2014-02-211-1/+1
| | | | | | Coverity Scan found this bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.akr2014-02-151-164/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS. (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX. (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT. (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN. (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN. (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P. (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P. (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG. (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK. (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT. (BIGNUM_LEN): Renamed from RBIGNUM_LEN. (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS. (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT. * bignum.c: Follow the above change. * gc.c: Ditto. * marshal.c: Ditto. * math.c: Ditto. * numeric.c: Ditto. * random.c: Ditto. * rational.c: Ditto. * sprintf.c: Ditto. * ext/-test-/bignum/bigzero.c: Ditto. * ext/-test-/bignum/intpack.c: Ditto. * ext/bigdecimal/bigdecimal.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_cmp): Avoid bignum allocation for comparisonakr2014-02-151-7/+11
| | | | | | | | between bignum and fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h,akr2014-02-141-118/+0
| | | | | | | | | | | | | | | | | | | | | include/ruby/io.h, include/ruby/ruby.h, include/ruby/win32.h, include/ruby/backward/rubysig.h, bignum.c, gc.c, io.c, process.c, safe.c, struct.c, thread.c, ext/socket/rubysocket.h, ext/-test-/old_thread_select: Remove deprecated definitions [ruby-core:60581] [Feature #9502] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC]akr2014-02-111-0/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_cmp): Specialize a comparison to zero.akr2014-02-111-1/+6
| | | | | | | | | * ext/bigdecimal/bigdecimal.c (is_negative): Use rb_big_cmp instead of RBIGNUM_NEGATIVE_P. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigxor_int): Apply BIGLO for long in a BDIGIT expression.akr2013-11-241-3/+3
| | | | | | | | | | (bigor_int): Ditto. (bigand_int): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/defines.h: Don't use int128_t for Bignum.akr2013-11-241-3/+1
| | | | | | | | | | It's not always faster. * bignum.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c: suppress warningnobu2013-11-191-1/+5
| | | | | | | * bignum.c (absint_numwords_generic): suppress false warning in rb_absint_numwords() by gcc 4.4. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c, math.c: RB_BIGNUM_TYPE_Pnobu2013-09-071-22/+24
| | | | | | | * bignum.c, math.c (RB_BIGNUM_TYPE_P): predicate macro like RB_FLOAT_TYPE_P. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e