summaryrefslogtreecommitdiff
path: root/numeric.c
AgeCommit message (Collapse)Author
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
2012-07-16* internal.h (rb_big_float_cmp): declared.akr
* bignum.c (rb_big_float_cmp): extracted from rb_big_cmp and big_op. (rb_big_cmp): use rb_big_float_cmp. (big_op): ditto. * numeric.c (flo_cmp): use rb_big_float_cmp. (flo_gt): ditto. (flo_ge): ditto. (flo_lt): ditto. (flo_le): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20numeric.c: optimizenobu
* numeric.c (positive_int_p, negative_int_p): optimize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20* numeric.c (positive_int_p, negative_int_p): extracted.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-15* reduce UNREACHABLE.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-14* variable.c (trace_ev): Removed "not reached" comment as this line isdrbrain
reached. * variable.c (rb_obj_remove_instance_variable): Replaced "not reached" comment with the UNREACHABLE macro. * variable.c (rb_mod_const_missing): ditto. * variable.c (rb_mod_remove_cvar): ditto. * enum.c (first_i): ditto. * string.c (rb_str_aref): ditto. * string.c (str_byte_aref): ditto. * string.c (rb_to_id): ditto. * io.c (rb_io_fmode_modestr): ditto. * io.c (rb_io_oflags_modestr): ditto. * pack.c (num2i32): ditto. * vm_eval.c (rb_method_missing): ditto. * vm_eval.c (rb_f_throw): ditto. * dir.c (dir_read): ditto. * win32/win32.c (child_result): ditto. * struct.c (rb_struct_getmember): ditto. * struct.c (rb_struct_set): ditto. * struct.c (rb_struct_aref_id): ditto. * eval.c (rb_f_raise): ditto. * process.c (rb_f_exit_bang): ditto. * process.c (rb_f_exit): ditto. * process.c (rb_f_abort): ditto. * ext/-test-/iter/break.c (iter_break_value): ditto. * ext/pty/pty.c (pty_check): ditto. * ext/openssl/ossl_pkey.c (ossl_pkey_new): ditto. * ext/readline/readline.c (rb_remove_history): ditto. * ext/stringio/stringio.c (strio_unimpl): ditto. * numeric.c (num_sadded): ditto. * numeric.c (num_init_copy): ditto. * numeric.c (rb_num2ll): ditto. * numeric.c (rb_num2ull): ditto. * vm_insnhelper.c (call_cfunc): ditto. * ruby.c (opt_W_getter): ditto. * bignum.c (rb_big_coerce): ditto. * file.c (rb_f_test): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15* adjust style.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14* include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]marcandre
* array.c: Use rb_check_arity / rb_error_arity * class.c: ditto * enumerator.c: ditto * eval.c: ditto * file.c: ditto * hash.c: ditto * numeric.c: ditto * proc.c: ditto * process.c: ditto * random.c: ditto * re.c: ditto * signal.c: ditto * string.c: ditto * struct.c: ditto * transcode.c: ditto * vm_eval.c: ditto * vm_insnhelper.c: ditto & implementation of rb_error_arity * test/ruby/test_arity.rb: tests for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14* numeric.c (flodivmod): must through the same pass if HAVE_FMOD or not.usa
this is a bugfix of r35013. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14* numeric.c: fix flodivmod for cornercases [Bug #6044]marcandre
add ruby_float_mod * insns.def (opt_mod): use ruby_float_mod * internal.h: declare ruby_float_mod * test/ruby/test_float.rb: tests for above * test/ruby/envutil.rb: create helper assert_is_minus_zero git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08* numeric.c (rb_enc_uint_char): raise RangeError when added codepointnaruse
is invalid. [Feature #5855] [Bug #5863] [Bug #5864] * string.c (rb_str_concat): ditto. * string.c (rb_str_concat): set encoding as ASCII-8BIT when the string is US-ASCII and the argument is an integer greater than 127. * regenc.c (onigenc_mb2_code_to_mbclen): rearrange error code. * enc/euc_jp.c (code_to_mbclen): ditto. * enc/shift_jis.c (code_to_mbclen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-22Fix for r33811.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-22* numeric.c (ruby_float_step): improve floating point calculations.naruse
[ruby-core:35753] [Bug #4576] * numeric.c (ruby_float_step): correct the error of floating point numbers on the excluding case. patched by Masahiro Tanaka [ruby-core:39608] * numeric.c (ruby_float_step): use the end value when the current value is greater than or equal to the end value. patched by Akira Tanaka [ruby-core:39612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-14* numeric.c (rb_fix2ushort): fix typo. use num rb_num2ushort()kosaki
instead of num2uint(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-14* include/ruby/ruby.h: add NUM2SHORT(), NUM2USHORT() macros.kosaki
* numeric.c: ditto. * test/-ext-/num2int/test_num2int.rb: add testcases for NUM2SHORT(). * ext/-test-/num2int/num2int.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-14* numeric.c (check_uint): fix off-by-one bug of NUM2UINT.kosaki
* bignum.c (rb_big2ulong): fix off-by-one bug of NUM2ULONG. * test/-ext-/num2int/test_num2int.rb: add a testcase for NUM2INT() NUM2UINT(), NUM2LONG(), NUM2ULONG(), NUM2LL and NUM2ULL(). * ext/-test-/num2int/depend: ditto. * ext/-test-/num2int/extconf.rb: ditto. * ext/-test-/num2int/num2int.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-23* numeric.c (rb_infinity, rb_nan): aggregated member initializersnobu
need braces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-21* numeric.c (rb_infinity, rb_nan): use union to prevent bus errorngoto
caused by misalignment. [Bug #5469] [ruby-dev:44657] * include/ruby/missing.h (INFINITY, NAN): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-05Revert r33407; half-baked patch.naruse
"* numeric.c (ruby_float_step): improve floating point calculations." git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-05* numeric.c (ruby_float_step): improve floating point calculations.naruse
[ruby-core:35753] [Bug #4576] * numeric.c (ruby_float_step): correct the error of floating point numbers on the excluding case. patched by Masahiro Tanaka [ruby-core:39608] * numeric.c (ruby_float_step): use the end value when the current value is greater than or equal to the end value. patched by Akira Tanaka [ruby-core:39612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29* use RB_TYPE_P which is optimized for constant types, instead ofnobu
comparison with TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-16Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."naruse
This reverts commit r33285 because of the message of r33284. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-16* numeric.c (ruby_float_step): Avoid error on i386 and amd64.marcandre
Patch by Vit Ondruch. Issue #4576 [rubyspec:a9525edcd] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-16Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."naruse
r33282 challenged the precision of floating point but: * Ruby keeps it as platform dependent * amd64 won't get this issue because compilers for amd64 uses SSE2 to calculate floating point numbers instead of x87 FPU. * this change won't fix the issue under -O * this commit has no test for the changed behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-15* numeric.c (ruby_float_step): Avoid error on i386 and amd64.marcandre
Patch by Vit Ondruch. Issue #4576. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-05* numeric.c (dbl2ival): Fix Float#divmod and #round for 32 bit platformmarcandre
part 1 of [bug #5276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e