aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* * numeric.c: Add description of that the results of the comparingmrkn2012-11-081-0/+14
| | | | | | | 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
* * numeric.c (ruby_float_step): fix r37514: it yielded with NaNnaruse2012-11-071-4/+10
| | | | | | if the unit is infinity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* adjust stylenobu2012-11-061-5/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_dotimes): Support for Integer#times.sizemarcandre2012-11-061-1/+13
| | | | | | [Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_upto, int_downto): Support for Integer#{down|up}to.sizemarcandre2012-11-061-2/+12
| | | | | | [Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (num_step): Support for Numeric#step.sizemarcandre2012-11-061-2/+40
| | | | | | [Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Extract ruby_float_step_sizemarcandre2012-11-061-24/+28
| | | | | | [Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_float_new_in_heap), include/ruby/ruby.h:ko12012-10-271-0/+1
| | | | | | | | | | | | | | | | 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
* * include/ruby/ruby.h: add C APIs.nari2012-10-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * include/ruby/ruby.h: introduce flonum technique forko12012-08-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Kernel#inspect: improve consistency and do not call #to_s.eregon2012-08-151-0/+2
| | | | | | | | | | | | | | | | | | | | * 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
* Revert r36699 and r36700. [Feature #6130]naruse2012-08-151-2/+0
| | | | | | | | | | | | | 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
* Kernel#inspect: improve consistency and do not call #to_s.eregon2012-08-141-0/+2
| | | | | | | | | | | | | | | 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
* * numeric.c (flo_to_s): use the exponential form if the integer partakr2012-07-161-1/+1
| | | | | | | | | 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
* * bignum.c (rb_integer_float_eq): new function.akr2012-07-161-2/+2
| | | | | | | | | | | | | (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
* * bignum.c (rb_integer_float_cmp): renamed from rb_big_float_cmp.akr2012-07-161-12/+12
| | | | | | | | | | * 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
* * bignum.c (rb_big_float_cmp): support fixnum for argument x.akr2012-07-161-25/+13
| | | | | | | | | | | | | | | | | | | * 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
* * internal.h (rb_big_float_cmp): declared.akr2012-07-161-14/+30
| | | | | | | | | | | | | | | | * 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
* numeric.c: optimizenobu2012-06-201-0/+20
| | | | | | * 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
* * numeric.c (positive_int_p, negative_int_p): extracted.nobu2012-06-201-16/+30
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * reduce UNREACHABLE.nobu2012-04-151-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * variable.c (trace_ev): Removed "not reached" comment as this line isdrbrain2012-04-141-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * adjust style.nobu2012-03-151-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]marcandre2012-03-141-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* * numeric.c (flodivmod): must through the same pass if HAVE_FMOD or not.usa2012-03-141-4/+4
| | | | | | | this is a bugfix of r35013. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: fix flodivmod for cornercases [Bug #6044]marcandre2012-03-141-10/+17
| | | | | | | | | | | | | | 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
* * numeric.c (rb_enc_uint_char): raise RangeError when added codepointnaruse2012-01-081-1/+10
| | | | | | | | | | | | | | | | | 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
* Fix for r33811.naruse2011-11-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (ruby_float_step): improve floating point calculations.naruse2011-11-221-4/+15
| | | | | | | | | | | | | | [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
* * numeric.c (rb_fix2ushort): fix typo. use num rb_num2ushort()kosaki2011-11-141-1/+1
| | | | | | | | instead of num2uint(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: add NUM2SHORT(), NUM2USHORT() macros.kosaki2011-11-141-0/+74
| | | | | | | | | | | * 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
* * numeric.c (check_uint): fix off-by-one bug of NUM2UINT.kosaki2011-11-141-1/+1
| | | | | | | | | | | | | | * 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
* * numeric.c (rb_infinity, rb_nan): aggregated member initializersnobu2011-10-231-4/+4
| | | | | | need braces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_infinity, rb_nan): use union to prevent bus errorngoto2011-10-211-4/+4
| | | | | | | | 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
* Revert r33407; half-baked patch.naruse2011-10-051-19/+4
| | | | | | "* 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
* * numeric.c (ruby_float_step): improve floating point calculations.naruse2011-10-051-4/+19
| | | | | | | | | | | | | | [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
* * use RB_TYPE_P which is optimized for constant types, instead ofnobu2011-09-291-5/+5
| | | | | | comparison with TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."naruse2011-09-161-3/+1
| | | | | | 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
* * numeric.c (ruby_float_step): Avoid error on i386 and amd64.marcandre2011-09-161-1/+3
| | | | | | 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
* Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."naruse2011-09-161-3/+1
| | | | | | | | | | | 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
* * numeric.c (ruby_float_step): Avoid error on i386 and amd64.marcandre2011-09-151-1/+3
| | | | | | Patch by Vit Ondruch. Issue #4576. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (dbl2ival): Fix Float#divmod and #round for 32 bit platformmarcandre2011-09-051-1/+1
| | | | | | part 1 of [bug #5276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): Fix criteria for 32 bits platformmarcandre2011-09-051-5/+5
| | | | | | part 2 of [bug #5276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): Make Float#round round big values [bug #5272]marcandre2011-09-041-34/+16
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Extract integer rounding into int_round_0marcandre2011-09-041-32/+41
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_round): Integer#round always returns an Integer [Bug #5271]marcandre2011-09-041-4/+13
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): substitute machine dependent magic number.nobu2011-09-011-5/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): Avoid overflow by optimizing for trivial casesmarcandre2011-08-311-6/+28
| | | | | | [Bug #5227] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (bit_coerce): A Fixnum and a Bignum are only permitted formrkn2011-08-291-4/+3
| | | | | | | | | | bitwise arithmetic with a Fixnum. #1792 * test/ruby/test_fixnum.rb: add tests for the above change. * bignum.c (bit_coerce): A Fixnum and a Bignum are only permitted for bitwise arithmetic with a Bignum. #1792 * test/ruby/test_bignum.rb: add tests for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_round): Fix Integer#round [ruby-core:39096]marcandre2011-08-241-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e