aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* [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
* * numeric.c: Mention that Float::DIG is the minimum numbermarcandre2014-03-021-1/+2
| | | | | | of siginificant digits. See #9191 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: predefined constantsnobu2014-02-281-3/+3
| | | | | | * numeric.c (id_eq, id_cmp): use predefined constants in id.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: float overflownobu2014-02-281-1/+2
| | | | | | | * numeric.c (ruby_num_interval_step_size): get rid of float conversion overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: integer overflownobu2014-02-281-1/+1
| | | | | | | * numeric.c (ruby_num_interval_step_size): get rid of integer overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Fix rdoc for stepmarcandre2014-02-281-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Fix Numeric#step with 0 unit [#9575]marcandre2014-02-281-3/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Simplify by getting rid of macromarcandre2014-02-281-10/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Create var for rb_intern("<=>")marcandre2014-02-281-3/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Simplify [ruby-core:61106] [Bug #9570]marcandre2014-02-281-13/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: check signs before divisionnobu2014-02-271-0/+11
| | | | | | | | * numeric.c (ruby_num_interval_step_size): check signs and get rid of implementation dependent behavior of negative division. [ruby-core:61106] [Bug #9570] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.akr2014-02-151-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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
* [DOC]akr2014-02-111-0/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: [DOC] Fix typo in example for #step [ci skip]zzak2014-01-311-2/+2
| | | | | | | Patch by @ksss [Fixes GH-522] https://github.com/ruby/ruby/pull/522 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: preserve encodingnobu2014-01-151-1/+1
| | | | | | * numeric.c (num_init_copy): preserve encoding of error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: preserve encodingnobu2014-01-151-3/+3
| | | | | | * numeric.c (num_sadded): preserve encoding of error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: FLOAT_OUT_OF_RANGEnobu2014-01-151-24/+21
| | | | | | | * numeric.c (FLOAT_OUT_OF_RANGE): extract a macro and a helper to raise RangeError of float. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: preserve encodingnobu2014-01-151-13/+11
| | | | | | * numeric.c (coerce_failed): preserve encoding of error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Fix typo in an error messagea_matsuda2014-01-071-1/+1
| | | | | | s/unsgined/unsigned/ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: isfinitenobu2014-01-051-2/+6
| | | | | | | * numeric.c (flo_is_finite_p): prefer C99 standard isfinite() than deprecated finite(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: no declaration of finitenobu2013-10-101-1/+1
| | | | | | | * numeric.c (finite): disable declaration on Windows, which can be defined in ruby/win32.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_aref): avoid a possible undefined behavior.mame2013-10-091-1/+1
| | | | | | | 1L << 63 on 64-bit platform is undefined, at least, according to ISO/IEC 9899 (C99) 6.5.7. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: move inline functionsnobu2013-09-251-0/+14
| | | | | | | | | * internal.h (rb_float_value, rb_float_new): move inline functions from ruby/ruby.h. * numeric.c (rb_float_value, rb_float_new): define external functions for extension libraries. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: use RB_TYPE_Pnobu2013-09-111-211/+184
| | | | | | | | * numeric.c: use RB_TYPE_P() for special classes instead of switch with TYPE(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: use positive_int_pnobu2013-09-071-1/+1
| | | | | | | * numeric.c (NUM_STEP_SCAN_ARGS): use positive_int_p() to fix rubyspec failures. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: no extra checksnobu2013-09-071-10/+0
| | | | | | | * numeric.c (NUM_STEP_SCAN_ARGS): remove extra class checks, which cause the incompatibilities. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: split NUM_STEP_GET_INFnobu2013-09-041-5/+10
| | | | | | | * numeric.c (NUM_STEP_GET_INF): split from NUM_STEP_SCAN_ARGS(), since inf is not used in num_step_size(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Retain behavior of Numeric#step when nil is given as second argument.knu2013-09-021-0/+3
| | | | | | | | | | | | | * numeric.c (NUM_STEP_SCAN_ARGS): On sencond thought, keep Numeral#step backward compatible in that it raises TypeError when nil is given as second argument. * test/ruby/test_float.rb (TestFloat#test_num2dbl): Revert. * test/ruby/test_numeric.rb (TestNumeric#test_step): Fix test cases for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Numeral#step should raise TypeError if a non-numeric parameter is given.knu2013-09-021-2/+16
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enhance Numeric#step.knu2013-09-021-40/+76
| | | | | | | | | | | * numeric.c (num_step): Default the limit argument to infinity and allow it to be omitted. Keyword arguments (by: and to:) are introduced for ease of use. [Feature #8838] [ruby-dev:47662] [ruby-dev:42194] * numeric.c (num_step): Optimize for infinite loop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_fix_bit_length): Moved from bignum.c.akr2013-09-011-0/+40
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e