aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* * numeric.c (int_pos_p): fix typos.kazu2016-03-281-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: rb_int2strnobu2016-03-261-0/+5
| | | | | | | * numeric.c (rb_int2str): conversion function to String for generic Integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: rb_int_roundnobu2016-03-261-11/+37
| | | | | | | * numeric.c (rb_int_round): rounding function for generic Integers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: basic arithmeticnobu2016-03-261-0/+73
| | | | | | | * numeric.c (rb_int_{uminus,plus,minus,mul,idiv,modulo}): basic arithmetic functions for generic Integers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: Fixnum predictsnobu2016-03-261-2/+6
| | | | | | | * numeric.c (FIXNUM_{POSITIVE,NEGATIVE,ZERO}_P): predict macros only for Fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (rb_fix_divmod_fix): like r54213, use FIX2NUM only ifnaruse2016-03-211-5/+5
| | | | | | | x == FIXNUM_MIN && y == -1. This must be a rare case and it is expected compiler to handle well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (DLONG): defined if long is 32bit (and LONG_LONG is 64bit;naruse2016-03-201-26/+1
| | | | | | | | | | | | | | | | but LONG_LONG is always defined as 64bit), or there's int128_t. * internal.h (DL2NUM): defined if DLONG is defined. * internal.h (rb_fix_mul_fix): defined for `Fixnum * Fixnum`. * insns.def (opt_mul): use rb_fix_mul_fix(). * numeric.c (fix_mul): ditto. * time.c (mul): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: optimize Fixnum<->Bignum comparisonsnobu2016-03-201-4/+4
| | | | | | | | * numeric.c (fix_gt, fix_ge, fix_lt, fix_le): optimize comparisons Fixnum against Bignum by rb_big_cmp in inversed order without new Bignum instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix r54193nobu2016-03-191-1/+6
| | | | | | | * numeric.c (fix_cmp): invert the result as the comarison is inverted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_cmp): use rb_big_cmp if x is Fixnum and y is Bignum.naruse2016-03-191-1/+1
| | | | | | rb_big_cmp handles such case smartly with big_norm. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_to_f): raise NotImplementedError when a receivermrkn2016-03-191-1/+1
| | | | | | | | | class is unknown. * test/-ext-/integer/test_my_integer.rb (test_my_integer_to_f): modify a test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (Bignum#<=>): remove it because they are unified withmrkn2016-03-191-13/+28
| | | | | | | | | | | | | | 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-1/+5
| | | | | | | | 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
* * numeric.c (int_to_f, fix_to_f): rename fix_to_f to int_to_f, and addmrkn2016-03-181-5/+10
| | | | | | | | | | | | | | | | | | | treatment for subclasses which don't have definitions of to_f method. * numeric.c (Integer#to_f, Fixnum#to_f): move to_f method from Fixnum to Integer. * ext/-test-/integer/my_integer.rb: define helper class for testing to_f method for a subclass of Integer. * ext/-test-/integer/extconf.rb: ditto. * ext/-test-/integer/init.c: ditto. * test/-ext-/integer/test_my_integer.rb: examine to_f method for a subclass of Integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (Bignum#eql?): remove its definition because it is unifiedmrkn2016-03-181-1/+7
| | | | | | | | 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-1/+9
| | | | | | | | 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
* * numeric.c (int_to_s): Move from flo_to_s.mrkn2016-03-181-6/+5
| | | | | | * numeric.c (Integer#to_s): Move from Fixnum#to_s. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_zero_p, fix_even_p, fix_odd_p): remove needlessmrkn2016-03-171-49/+0
| | | | | | functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_even_p): treat Fixnum and Bignum values directly.mrkn2016-03-171-1/+9
| | | | | | I forgot include this commit in the previous one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (Bignum#even?, Bignum#odd?): remove definitionsmrkn2016-03-171-5/+18
| | | | | | | | | | | | | | | | 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
* * numeric.c (num_step): use rb_equal for zero check. rb_num_coerce_cmpmame2016-03-171-1/+1
| | | | | | created an object which caused extra overhead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_inject): Implement the specialized code for sum ofakr2016-03-171-0/+6
| | | | | | | | | | | | integers including Bignums. * internal.h (rb_fix_plus): Declared to be usable from enum_inject. * numeric.c (rb_fix_plus): Defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix2str): improve r54092 like rb_int2big().naruse2016-03-141-11/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: fix edge casenobu2016-03-131-1/+9
| | | | | | | * numeric.c (rb_fix2str): fix edge case, accidentally generated wrong Fixnum from LONG_MIN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * intern.h (rb_divmod): assume compilers `/` and `%` comply C99naruse2016-03-081-39/+7
| | | | | | | | | | | | | | | | | | | | | | and reduce branching. If a compiler doesn't comply, add #ifdefs. * intern.h (rb_div): added for Ruby's behavior. * intern.h (rb_mod): added for Ruby's behavior. * insns.def (opt_div): use rb_div. * insns.def (opt_mod): use rb_mod. * numeric.c (fixdivmod): removed. * numeric.c (fix_divide): use rb_div. * numeric.c (fix_mod): use rb_mod. * numeric.c (fix_divmod): use rb_divmod. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: wrong type step should raise TypeErrornobu2016-02-261-1/+29
| | | | | | | | * numeric.c (num_step_scan_args): comparison String with Numeric should raise TypeError. it is an invalid type, but not a mismatch the number of arguments. [ruby-core:62430] [Bug #9810] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: micro optimizationsnobu2016-02-241-5/+7
| | | | | | | * numeric.c (flo_to_s, rb_fix2str): use rb_usascii_str_new instead of rb_usascii_str_new_cstr, when the length can be calculated. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: adjust typesnobu2016-02-171-2/+2
| | | | | | | * numeric.c (coerce_rescue, coerce_rescue_quiet): rescue functions should have errinfo too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: adjust typesnobu2016-02-171-4/+6
| | | | | | | * numeric.c (coerce_body, coerce_rescue, coerce_rescue_quiet): adjust parameter types for rb_rescue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: fix segfaultnobu2016-02-161-1/+1
| | | | | | | * numeric.c (compare_with_zero): fix variable name, rb_cmperr requires VALUEs but not an ID. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: fix a typo in documentation.hsbt2015-12-141-1/+1
| | | | | | | | | | | | [ci skip][fix GH-1140] Patch by @jutaz * io.c: ditto. * iseq.c: ditto. * numeric.c: ditto. * process.c: ditto. * string.c: ditto. * vm_trace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Good-by Borland-C.kosaki2015-10-181-4/+0
| | | | | | | | | | | | | | | | * include/ruby/backward/rubyio.h: ditto. * include/ruby/backward/st.h: ditto. * include/ruby/backward/util.h: ditto. * include/ruby/backward/rubysig.h: ditto. * include/ruby/backward/classext.h: ditto. * dln.c: ditto. * gc.c: ditto. * win32/resource.rb: ditto. * win32/dir.h: ditto. * ext/tk/tcltklib.c: ditto. * NEWS: announce that Borland-C is no longer supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: use predefined IDsnobu2015-10-121-20/+21
| | | | | | * numeric.c: use predefined IDs and prepared IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: common expressionsnobu2015-10-121-9/+10
| | | | | | * numeric.c (flo_pow): extract common expressions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_eval.c, internal.h (rb_yield_1): added for performance whichko12015-10-101-1/+1
| | | | | | | | | doesn't check Qundef. * numeric.c (int_dotimes): use rb_yield_1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.svn2015-10-051-17/+17
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: [DOC] Overview for Numeric class by Joe Corcoranzzak2015-10-051-1/+69
| | | | | | | This patch was created at ROSSConf Berlin 2015 [Bug #11555] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* preserve encodings in error messagesnobu2015-09-281-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (Init_Numeric): Fix document for Float::MIN andakr2015-08-111-2/+7
| | | | | | | | Float::EPSILON. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix doc for Numeric#coerce [ci skip]nobu2015-07-221-1/+1
| | | | | | | * numeric.c (num_coerce): [DOC] fix doc for Numeric#coerce, missing '+'. [Fix GH-974] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (Numeric#negative?): [DOC] Fix call-seq.eregon2015-05-241-1/+1
| | | | | | Patch by @yui-knk. [Fixes GH-908] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: return truenobu2015-05-191-3/+3
| | | | | | | * numeric.c (num_positive_p): return true instead of Fixnum 0. [ruby-core:69173] [Feature #11151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: Bignum 0 is not positivenobu2015-05-191-1/+1
| | | | | | | | * numeric.c (num_positive_p): should false on Bignum 0. http://twitter.com/rafaelfranca/status/600509783427391488 [ruby-core:69173] [Feature #11151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: Numeric#positive? and Numeric#negative?nobu2015-05-171-0/+68
| | | | | | | | | | | | * numeric.c (num_positive_p, num_negative_p): add methods Numeric#positive? and Numeric#negative?. [ruby-core:69173] [Feature #11151] * numeric.c (flo_positive_p, flo_negative_p): specialiazed functions for Float. * complex.c (Init_Complex): Complex do not have positive? and negative? methods git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: compare_with_zeronobu2015-05-171-2/+13
| | | | | | | * numeric.c (compare_with_zero): raise TypeError when not comparable with 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: same hash values with Float#hashnobu2015-03-181-2/+6
| | | | | | | | * hash.c (rb_any_hash): use same hash values with Float#hash so that -0.0 and +0.0 will be identical. [ruby-core:68541] [Bug #10979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: calculate complex numbersnobu2015-02-241-0/+8
| | | | | | | * numeric.c (fix_plus, fix_mul): calculate complex numbers for commutative operations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use rb_funcallvnobu2015-02-161-2/+2
| | | | | | | * use rb_funcallv() for no arguments call instead of variadic rb_funcall(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: fix messagenobu2015-01-131-2/+7
| | | | | | | * numeric.c (coerce_failed): fix the error message on non-flonum platforms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: correct error message when coerce failsnormal2015-01-121-1/+2
| | | | | | | | * numeric.c (bit_coerce): use original value for error message [ruby-core:67405] [Bug #10711] * test/ruby/test_numeric.rb (test_coerce): check error message git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e