summaryrefslogtreecommitdiff
path: root/numeric.c
AgeCommit message (Collapse)Author
2013-06-08* numeric.c (rb_num_to_uint): Use rb_absint_size instead ofakr
RBIGNUM_LEN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* rational.c (numeric_quo): move num_quo in numeric.c to numeric_quomrkn
in rational.c to refer canonicalization state for mathn support. [ruby-core:41575] [Bug #5736] * numeric.c (num_quo): ditto. * test/test_mathn.rb: add a test for the change at r41109. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06* numeric.c: remove unused ID id_to_r introduced in r41109.eregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06* numeric.c (num_quo): Use to_r method to convert the receiver tomrkn
rational. [ruby-core:41575] [Bug #5736] * test/ruby/test_numeric.rb: add a test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06* numeric.c (num_quo): should return a Float for a Float argument.mrkn
[ruby-dev:44710] [Bug #5515] * test/ruby/test_fixnum.rb: Add an assertion for the above change. * test/ruby/test_bignum.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* gc.c: support RGENGC. [ruby-trunk - Feature #8339]ko1
See this ticet about RGENGC. * gc.c: Add several flags: * RGENGC_DEBUG: if >0, then prints debug information. * RGENGC_CHECK_MODE: if >0, add assertions. * RGENGC_PROFILE: if >0, add profiling features. check GC.stat and GC::Profiler. * include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0). * array.c: add write barriers for T_ARRAY and generate sunny objects. * include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if you want to access raw pointers. If you modify the contents which pointer pointed, then you need to care write barrier. * bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects. * complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX and generate sunny objects. * rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write barriers for T_RATIONAL and generate sunny objects. * internal.h: add write barriers for RBasic::klass. * numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects. * object.c (rb_class_allocate_instance), range.c: generate sunny T_OBJECT objects. * string.c: add write barriers for T_STRING and generate sunny objects. * variable.c: add write barriers for ivars. * vm_insnhelper.c (vm_setivar): ditto. * include/ruby/ruby.h, debug.c: use two flags FL_WB_PROTECTED and FL_OLDGEN. * node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED): move flag bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* *.c, parse.y, insns.def: use RARRAY_AREF/ASET macroko1
instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24* numeric.c: Fix wiki link on Float imprecision in overview, patchedzzak
by Makoto Kishimoto [Bug #8304] [ruby-dev:47280] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12* array.c: Document synonymous methods, by windwiny [GH-277]zzak
* bignum.c: ditto * complex.c: ditto * dir.c: ditto * encoding.c: ditto * enumerator.c: ditto * numeric.c: ditto * proc.c: ditto * re.c: ditto * string.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09* internal.h (MUL_OVERFLOW_SIGNED_INTEGER_P): New macro.akr
(MUL_OVERFLOW_FIXNUM_P): Ditto. (MUL_OVERFLOW_LONG_P): Ditto. * array.c (rb_ary_product): Don't overflow on signed integer multiplication. * numeric.c (fix_mul): Ditto. (int_pow): Ditto. * rational.c (f_imul): Ditto. * insns.def (opt_mult): Ditto. * thread.c (sleep_timeval): Don't overflow on signed integer addition. * bignum.c (rb_int2big): Don't overflow on signed integer negation. (rb_big2ulong): Ditto. (rb_big2long): Ditto. (rb_big2ull): Ditto. (rb_big2ll): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-01* numeric.c (rb_num2ulong_internal): Don't cast a negative double valueakr
into unsigned long, which is undefined behavior. (rb_num2ull): Don't cast a value bigger than LLONG_MAX into long long, which is undefined behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-01* numeric.c (rb_num2long): Don't use SIGNED_VALUE uselessly.akr
(check_int): Ditto. (check_short): Ditto. (rb_num2fix): Ditto. (rb_num2ulong_internal): Add a cast. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-01* numeric.c (check_uint): Take the 1st argument as unsigned long,akr
instead of VALUE. Refine the validity test conditions. (check_ushort): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-31* numeric.c (rb_num2ulong_internal): New function similart toakr
rb_num2ulong but integer wrap around flag is also returned. (rb_num2ulong): Use rb_num2ulong_internal. (rb_num2uint): Use rb_num2ulong_internal and the wrap around flag is used instead of negative_int_p(val). (rb_num2ushort): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-28* numeric.c (rb_num2ull): Cast double to unsigned LONG_LONG viaakr
LONG_LONG instead of double to unsigned LONG_LONG directly. This is a challenge to fix a test_num2ull(TestNum2int) failure (NUM2ULL(-1.0) should be "18446744073709551615" but was "0") on Mac OS X with 32bit clang. http://a.mrkn.jp/~mrkn/chkbuild/mountain_lion/ruby-trunk-m32-o0/log/20130328T191100Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-27* numeric.c (LONG_MIN_MINUS_ONE_IS_LESS_THAN): New macro.akr
(LLONG_MIN_MINUS_ONE_IS_LESS_THAN): Ditto. (rb_num2long): Use LONG_MIN_MINUS_ONE_IS_LESS_THAN. (rb_num2ulong): Ditto. (rb_num2ll): Use LLONG_MIN_MINUS_ONE_IS_LESS_THAN. (rb_num2ull): Ditto. * test/-ext-/num2int/test_num2int.rb (asert_num2i_success): Test the value converted into a Float if Float can represent the value exactly. (asert_num2i_error): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-06prefix global symbolsnobu
* iseq.c (rb_insn_operand_intern): prefix global symbols. * numeric.c (ruby_num_interval_step_size): ditto. * vm_backtrace.c (rb_vm_backtrace_str_ary), (rb_vm_backtrace_location_ary, rb_vm_thread_backtrace), (rb_vm_thread_backtrace_locations): ditto. * vm_trace.c (rb_vm_trace_mark_event_hooks): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05enumerator.c: allow Bignum for with_indexnobu
* enumerator.c (enumerator_with_index_i): allow Bignum as offset, to get rid of conversion exception and integer overflow. [ruby-dev:47131] [Bug #8010] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05numeric.c: optimize for Bignumnobu
* numeric.c (rb_int_succ, rb_int_pred): shortcut optimization for Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23* array.c: Document #<=> return values and formattingzzak
* bignum.c: ditto * file.c: ditto * object.c: ditto * numeric.c: ditto * rational.c: ditto * string.c: ditto * time.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22random.c: fix error messagenobu
* random.c (rb_random_ulong_limited): fix error message for negative value. [ruby-dev:47061] [Bug #7903] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22* numeric.c: Examples and formatting for Numeric and Floatzzak
Based on a patch by Zach Morek and Oren K of newhaven.rb [Github documenting-ruby/ruby#5] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05* numeric.c (fix_pow): Handle special cases when base is 0, -1 or +1marcandre
[Bug #5713] [Bug #5715] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05* numeric.c: Fix rdoc for Fixnum#**marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-03* numeric.c: Document Float constants [ruby-core:51484] [Bug #7709]zzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-12* numeric.c (do_coerce): fix for the exceptions which the coercemrkn
method raises. The optimization done by r38756 is preserved. [Bug #7645] [ruby-core:51213] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10* numeric.c (do_coerce): fix comment and adjust indenteregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10* numeric.c (do_coerce): remove an unused variable.shugo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10* numeric.c (do_coerce): speed optimization by using rb_check_funcallmrkn
instead of rb_rescue + rb_funcall. This fix is based on the patch by Benoit Daloze. [Bug #7645] [ruby-core:51213] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29use RB_TYPE_Pnobu
* enumerator.c (enumerator_initialize), eval.c (rb_using_refinement), (add_activated_refinement), numeric.c (num_interval_step_size), parse.y (arg, match_op_gen, cond0), range.c (range_bsearch), vm_insnhelper.c (vm_get_iclass): use RB_TYPE_P() to optimize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22* include/ruby/intern.h: add the prototype declaration ofmrkn
rb_num_coerce_bit. * numeric.c (rb_num_coerce_bit): the new coerce function for bitwise binary operation. * bignum.c (rb_big_and): use coerce to convert the argument, which isn't a Fixnum nor a Bignum, to the corresponding Integer object so that bitwise operations can support Integer-mimic objects. [Bug #1792] [ruby-core:39491] * bignum.c (rb_big_or): ditto. * bignum.c (rb_big_xor): ditto. * numeric.c (bit_coerce): ditto. * numeric.c (fix_and): ditto. * numeric.c (fix_or): ditto. * numeric.c (fix_xor): ditto. * test/ruby/test_integer.rb: add tests for the above changes. * test/ruby/test_bignum.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02* array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,ko1
range.c: use prepared IDs. A patch from charliesome (Charlie Somerville). [Bug #7495] * common.mk: add dependency to id.h. * common.mk: replace ID_H_INCLUDES with id.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01adjust style.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-08* numeric.c: Add description of that the results of the comparingmrkn
operations of two NaNs are undefined. [#1720] [ruby-dev:38725] [ruby-core:36966] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-07* numeric.c (ruby_float_step): fix r37514: it yielded with NaNnaruse
if the unit is infinity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06adjust stylenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* numeric.c (int_dotimes): Support for Integer#times.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* numeric.c (int_upto, int_downto): Support for Integer#{down|up}to.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* numeric.c (num_step): Support for Numeric#step.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* numeric.c: Extract ruby_float_step_sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27* numeric.c (rb_float_new_in_heap), include/ruby/ruby.h:ko1
make all Float objects frozen. [ruby-dev:46081] [ruby-trunk - Feature #6936] Most part of patch by NARUSE, Yui <naruse@ruby-lang.org>. * class.c (singleton_class_of): raise TypeError when trying to define a singleton method on Float objects. * vm.c (vm_define_method): ditto. * test/ruby/marshaltestlib.rb: catch up above changes. * test/ruby/test_class.rb: ditto. * test/test_pp.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20* include/ruby/ruby.h: add C APIs.nari
VALUE rb_newobj_of(VALUE klass, VALUE flags) #define NEWOBJ_OF(obj,type,klass,flags) These allow to change a allocation strategy depending on klass or flags. * gc.c: ditto * array.c: use new C API. * bignum.c: ditto * class.c: ditto * complex.c: ditto * ext/socket/ancdata.c: ditto * ext/socket/option.c: ditto * hash.c: ditto * io.c: ditto * marshal.c: ditto * numeric.c: ditto * object.c: ditto * random.c: ditto * range.c: ditto * rational.c: ditto * re.c: ditto * string.c: ditto * struct.c: ditto [Feature #7177][Feature #7047] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23* include/ruby/ruby.h: introduce flonum technique forko1
64bit CPU environment (sizeof(double) == sizeof(VALUE)). flonum technique enables to avoid double object creation if the double value d is in range about between 1.72723e-77 < |d| <= 1.15792e+77 or 0.0. flonum Float value is immediate and their lowest two bits are b10. If flonum is activated, then USE_FLONUM macro is 1. I'll write detailed in this technique on https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/Flonum_tech * benchmark/bmx_temp.rb: add an benchmark for simple Float calculation. * gc.c (id2ref, rb_obj_id): add flonum Float support. * include/ruby/intern.h: move decl of rb_float_new(double) to include/ruby/ruby.h. * insns.def, vm.c, vm_insnhelper.c: add flonum optimization and simplify source code. * vm_insnhelper.h (FLONUM_2_P): added. * marshal.c: support flonum output. * numeric.c (rb_float_new_in_heap): added. * parse.y: support flonum. * random.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15Kernel#inspect: improve consistency and do not call #to_s.eregon
* object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s. A class can now benefit from the nice default #inspect even if it defines #to_s. Also, there is no more unexpected change in #inspect result. * NEWS: Add note about the change. * bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*): Adapt internal structures (by aliasing #inspect to #to_s) so they don't rely on the removed behavior (#inspect calling overridden #to_s). * test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect. * lib/pp.rb (class PP): do not call #to_s anymore, as #inspect no more does (mame). * test/test_pp.rb (class PPInspectTest): remove related assertion (mame). [ruby-core:43238][Feature #6130] * test/drb/drbtest.rb (DRbCore#teardown, DRbAry#teardown): adapt DRb tests with the new change (shirosaki). [ruby-core:47182][Bug #6866] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15Revert r36699 and r36700. [Feature #6130]naruse
Revert "Kernel#inspect: improve consistency and do not call #to_s." Revert "update PP with recent Kernel#inspect change. Patch by Yusuke Endoh." r36699 cause test-all failure on test/drb/test_drb.rb and test/drb/test_drbssl.rb. Run test-all before commit. Moreover its ChangeLog formst is wrong: see CommitterHowto https://bugs.ruby-lang.org/projects/ruby/wiki/CommitterHowto#ChangeLog git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-14Kernel#inspect: improve consistency and do not call #to_s.eregon
A class can now benefit from the nice default #inspect even if it defines #to_s. Also, there is no more unexpected change in #inspect result. Internal structures have been adapted so they don't rely on the removed behavior (#inspect calling overridden #to_s). * object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s. * test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect. * bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*): alias #inspect to #to_s where it was expected. [ruby-core:43238][Feature #6130] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-16* numeric.c (flo_to_s): use the exponential form if the integer partakr
is longer than or equal DBL_DIG. [ruby-dev:45960] [ruby-trunk - Bug #6741] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-16* bignum.c (rb_integer_float_eq): new function.akr
(rb_big_eq): use rb_integer_float_eq. * internal.h (rb_integer_float_eq): declared. * numeric.c (flo_eq): use rb_integer_float_eq. (fix_equal): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-16* bignum.c (rb_integer_float_cmp): renamed from rb_big_float_cmp.akr
* internal.h: follow the above change. * numeric.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-16* bignum.c (rb_big_float_cmp): support fixnum for argument x.akr
* numeric.c (fix_equal): use rb_big_float_cmp. (fix_cmp): ditto. (fix_gt): ditto. (fix_ge): ditto. (fix_lt): ditto. (fix_le): ditto. (flo_eq): ditto. (flo_cmp): use rb_big_float_cmp for fixnum argument. (flo_gt): ditto. (flo_ge): ditto. (flo_lt): ditto. (flo_le): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e