aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* * 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
* * internal.h: Gather declarations in non-header files.akr2014-11-181-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-3/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * dir.c (glob_helper): use #ifdef instead of #if.ko12014-09-041-1/+1
| | | | | | | | | | | gcc's -Wundef option shows warning for undefined macro. * numeric.c (flo_is_finite_p): ditto. * vm_dump.c (rb_vmdebug_thread_dump_state): ditto. * vm_core.h: define VM_DEBUG_VERIFY_METHOD_CACHE to 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: 0 % Float::NAN returns Float::NANnobu2014-08-011-1/+7
| | | | | | | * numeric.c (flodivmod): all results are NaN if divisor is NaN. [fix GH-692] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (num_step_scan_args): table argument of rb_get_kwargs() isnagachika2014-07-011-5/+5
| | | | | | array of IDs, not Symbols. [ruby-dev:48353] [Bug #9811] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (do_coerce): Add a warning when an exception is raisederegon2014-06-071-1/+15
| | | | | | | | | | | | or an invalid value is returned in #coerce called by numeric comparison operators and the exception thrown by the caller has no information on the failure. In the next release such exception should not be rescued or should be the cause of the caller exception. nil is accepted as the "no possible coercion" return value. See #7688. * test/ruby/test_numeric.rb: Add corresponding test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (bit_coerce): remove constant parameter `err'eregon2014-06-071-7/+6
| | | | | | (always TRUE) of bit_coerce(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* encoding.h: constify rb_encodingnobu2014-06-021-1/+1
| | | | | | | * include/ruby/encoding.h: constify `rb_encoding` itself, not only arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* constify rb_encoding and OnigEncodingnobu2014-06-011-1/+1
| | | | | | | * include/ruby/encoding.h: constify `rb_encoding` arguments. * include/ruby/oniguruma.h: constify `OnigEncoding` arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* id.def: predefine to_inobu2014-05-201-2/+2
| | | | | | | | | | * defs/id.def: predefine `to_i` as well as `to_int`. * numeric.c (id_to_i): use predefined `idTo_i`. * object.c (conv_method_names): add `to_i` ID. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: Check nextafter() availability.akr2014-05-181-0/+115
| | | | | | | | | | | | | | * include/ruby/missing.h (nextafter): New optional declaration. * missing/nextafter.c: New file. * numeric.c: Float#next_float and Float#prev_float implemented. [ruby-core:62562] [Feature #9834] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: check keyword argumentsnobu2014-05-071-2/+13
| | | | | | | | * numeric.c (num_step_scan_args): check keyword arguments and fail if they conflict with positional arguments. [ruby-dev:48177] [Bug #9811] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: merge missnobu2014-05-071-2/+2
| | | | | | * numeric.c (num_step_scan_args): fix merge miss. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: num_step_scan_argsnobu2014-05-071-28/+33
| | | | | | * numeric.c (num_step_scan_args): turn a macro into a function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: indentnobu2014-05-071-2/+2
| | | | | | * numeric.c (ruby_num_interval_step_size): adjust indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45858 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
* * enumerator.c (enumerator_block_call): use PARRAY_CONST_PTR()ko12014-03-171-1/+1
| | | | | | | | | | | | instead of RARRAY_PTR(). * io.c (rb_io_s_popen): ditto. * numeric.c (num_step_size): ditto. * vm_eval.c (rb_apply): ditto. * vm_eval.c (rb_eval_cmd): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e