Граф коммитов

489 Коммитов

Автор SHA1 Сообщение Дата
marcandre f02c29ee4f * numeric.c: Extract ruby_float_step_size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:14:16 +00:00
ko1 180c744b3b * numeric.c (rb_float_new_in_heap), include/ruby/ruby.h:
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-27 02:10:53 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
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-10-20 06:57:51 +00:00
ko1 b3b5e626ad * include/ruby/ruby.h: introduce flonum technique for
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-23 07:22:40 +00:00
eregon fd7dc23d28 Kernel#inspect: improve consistency and do not call #to_s.
* 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-15 11:50:01 +00:00
naruse 780e7d0951 Revert r36699 and r36700. [Feature #6130]
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-15 01:09:10 +00:00
eregon 795c29dcda Kernel#inspect: improve consistency and 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. 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-08-14 10:20:44 +00:00
akr 0e2aa330ec * numeric.c (flo_to_s): use the exponential form if the integer part
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 13:52:10 +00:00
akr 04f09ef8a1 * bignum.c (rb_integer_float_eq): new function.
(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 10:39:42 +00:00
akr cf469774d1 * bignum.c (rb_integer_float_cmp): renamed from rb_big_float_cmp.
* 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 09:41:25 +00:00
akr 984729ba30 * bignum.c (rb_big_float_cmp): support fixnum for argument x.
* 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 08:44:32 +00:00
akr 6dd65bb377 * internal.h (rb_big_float_cmp): declared.
* 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-07-16 06:02:21 +00:00
nobu 50aab6d401 numeric.c: optimize
* 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 06:31:35 +00:00
nobu f96afe182e * numeric.c (positive_int_p, negative_int_p): extracted.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 06:31:32 +00:00
nobu 57fb219905 * reduce UNREACHABLE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-15 00:06:13 +00:00
drbrain e95f7ea80d * variable.c (trace_ev): Removed "not reached" comment as this line is
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-04-14 00:36:26 +00:00
nobu c037f1f616 * adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 01:39:00 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* 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 21:10:34 +00:00
usa cc3d03b196 * numeric.c (flodivmod): must through the same pass if HAVE_FMOD or not.
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 08:56:42 +00:00
marcandre 4c2e2d8bde * numeric.c: fix flodivmod for cornercases [Bug #6044]
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-03-14 06:10:01 +00:00
naruse 800f04c6a5 * numeric.c (rb_enc_uint_char): raise RangeError when added codepoint
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
2012-01-08 20:42:45 +00:00
naruse cc56bdee40 Fix for r33811.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-22 04:54:42 +00:00
naruse 033244c1b2 * numeric.c (ruby_float_step): improve floating point calculations.
[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-22 01:47:35 +00:00
kosaki 302220a8a5 * numeric.c (rb_fix2ushort): fix typo. use num rb_num2ushort()
instead of num2uint().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-14 05:53:59 +00:00
kosaki b2a2ba1191 * include/ruby/ruby.h: add NUM2SHORT(), NUM2USHORT() macros.
* 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 03:54:34 +00:00
kosaki 74a13c7634 * numeric.c (check_uint): fix off-by-one bug of NUM2UINT.
* 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-11-14 03:45:47 +00:00
nobu bb98e0ecec * numeric.c (rb_infinity, rb_nan): aggregated member initializers
need braces.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-23 09:03:33 +00:00
ngoto 971769cd76 * numeric.c (rb_infinity, rb_nan): use union to prevent bus error
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-21 17:34:58 +00:00
naruse 0a5ac6a448 Revert r33407; half-baked patch.
"* 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 07:36:28 +00:00
naruse a635de7dcb * numeric.c (ruby_float_step): improve floating point calculations.
[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-10-05 07:35:27 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
naruse 8ccd05c958 Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."
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 07:09:24 +00:00
marcandre fd47fed269 * numeric.c (ruby_float_step): Avoid error on i386 and amd64.
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-16 06:44:59 +00:00
naruse 23d472165f Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."
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-16 01:12:46 +00:00
marcandre 22420b1453 * numeric.c (ruby_float_step): Avoid error on i386 and amd64.
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-15 17:13:51 +00:00
marcandre 80f54e6810 * numeric.c (dbl2ival): Fix Float#divmod and #round for 32 bit platform
part 1 of [bug #5276]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-05 21:45:25 +00:00
marcandre 3dc28710c9 * numeric.c (flo_round): Fix criteria for 32 bits platform
part 2 of [bug #5276]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-05 21:44:42 +00:00
marcandre 75c42535c9 * numeric.c (flo_round): Make Float#round round big values [bug #5272]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-04 20:14:29 +00:00
marcandre 269de36cd0 * numeric.c: Extract integer rounding into int_round_0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-04 20:14:00 +00:00
marcandre 9d2f5dff62 * numeric.c (int_round): Integer#round always returns an Integer [Bug #5271]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-04 19:28:54 +00:00
nobu c4eb2983ba * numeric.c (flo_round): substitute machine dependent magic number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-01 16:07:16 +00:00
marcandre 64e0cae274 * numeric.c (flo_round): Avoid overflow by optimizing for trivial cases
[Bug #5227]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-31 04:13:00 +00:00
mrkn 640420f704 * numeric.c (bit_coerce): A Fixnum and a Bignum are only permitted for
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
2011-08-29 01:07:15 +00:00
marcandre 85e24491a6 * numeric.c (int_round): Fix Integer#round [ruby-core:39096]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-24 22:57:55 +00:00
marcandre ee0d942ed9 * numeric.c: Rdoc fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-24 22:57:42 +00:00
ngoto 9fb5dca9c9 * numeric.c (rb_infinity, rb_nan): use WORDS_BIGENDIAN to get endian.
fix [Bug #5160] [ruby-dev:44356]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-05 13:28:50 +00:00
usa 12adf25a80 * numeric.c (rb_num2ull): use FIX2LONG instead of FIX2ULONG. see
rb_num2ulong().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-11 06:03:41 +00:00
nobu 03c618daf0 * numeric.c (ULLONG_MAX): fallback definition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-09 07:54:38 +00:00
naruse 136c117fc1 * numeric.c (rb_num2ull): use own switch sentense.
Current implementation can't convert 18446744073709551615.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-07 06:23:40 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
nobu 6f58118e4c * numeric.c (rb_enc_uint_chr): fix message format. Bug#4869
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-11 07:52:34 +00:00
usa 799fafc03b * include/ruby/missing.h, numeric.c (round): moved prototype of round()
from numeric.c to missing.h.  (note: round() is C99 feature, so ruby
  provides it if not exists in C runtime.)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-03 11:58:11 +00:00
naruse 1d5431374d * insns.def (opt_mult): as r31805, volatile it.
Without this, clang -O fails calculation.

* numeric.c (fix_mul): ditto.

* rational.c (f_imul): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-30 06:53:21 +00:00
naruse 4e4649e13c * numeric.c (int_pow): make sure to assign the result of x * z.
If xz is optimized out, the value won't overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-30 01:28:37 +00:00
nobu 3b58e17d7b revert r31783.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-29 22:06:54 +00:00
nobu 7c99a7df85 * numeric.c (flo_round): use absolute value as divisor.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-29 14:22:49 +00:00
nagachika 4173fb0cb5 * numeric.c: add #include "interna.h" for rb_big_uminus() prototype.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-29 08:55:54 +00:00
nobu a3ffe9698b * numeric.c (flo_round): fix for negative value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-29 06:09:08 +00:00
nobu 3a47cf3395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15 11:55:52 +00:00
nagachika a55d803ed3 * numeric.c (flo_coerce): fix a typo in documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-13 12:38:49 +00:00
shyouhei eb5de217f1 Add #flo_coerce documentation.
Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org>



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-13 10:27:10 +00:00
naruse 074818f3b0 * numeric.c (int_ord): remove K&R style.
patched by Daehyub Kim. https://github.com/ruby/ruby/pull/17

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-09 02:53:55 +00:00
usa 9d5f651a98 * numeric.c (ruby_float_step): wrong loop condition.
fixes [ruby-core:35753], reported by Joey Zhou.

* test/ruby/test_range.rb (TestRange#test_step_ruby_core_35753):
  test above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-14 14:50:46 +00:00
nobu 9b66922d7f * numeric.c (flo_round): fix inaccurate results.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-22 23:07:36 +00:00
naruse 2c1936cf87 * numeric.c (flo_round): use pow instead of while-loop. fixes #4510
patched by Alex Young [ruby-core:35526]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-22 01:08:49 +00:00
usa 91d2ee737d * numeric.c (Init_Numeric): fixed a potential bug when using bccwin32
ruby with Microsoft's dll, though we already gave up of supporting
  bccwin32. [ruby-core:33503]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-01 13:05:17 +00:00
naruse ded94d1c8c * numeric.c (ruby_float_step): fix Numeric#step with infinity unit
doesn't works well. [ruby-core:32779]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13 19:17:49 +00:00
nobu 9d0c732f0d * numeric.c (check_uint): get rid of overflow on LLP64 platforms.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13 13:53:22 +00:00
naruse 74dcda0d41 * numeric.c (int_chr): raise error when the value is negative.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13 12:13:53 +00:00
naruse e79fbf3dfe * numeric.c (rb_num_to_uint): fix 32bit logic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13 05:58:35 +00:00
naruse a01e628318 * numeric.c (rb_num_to_uint): added to check the range of arguments.
Mainly for negative value with NUM2UINT on 32bit environment.

* string.c (rb_str_concat): use rb_num_to_uint.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13 03:56:31 +00:00
nobu 2f0b8e2793 * numeric.c (rb_num2fix): result of rb_num2long is SIGNED_VALUE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 14:54:06 +00:00
naruse 2d8612e966 * numeric (check_uint): the mask must refer to VALUE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 08:56:00 +00:00
naruse 232257238a * numeric (check_uint): set MSB for negative value.
* numeric (rb_num2uint): return value's type of rb_num2ulong
  is VALUE.

* numeric (int_chr): variable i can't be negative.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 08:50:30 +00:00
naruse e960fffda1 * numeric.c (rb_enc_uint_chr): split from int_chr.
* numeric.c (int_chr): use rb_enc_uint_chr.

* include/ruby/encoding.h (rb_enc_uint_chr): added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 06:18:08 +00:00
naruse 6913b2734a * numeric.c (int_chr): a codepoint of Ruby M17N must be 32bit
unsigned int; GB18030 uses MSB. Also note that OnigCodePoint
  is defined as uisigned int.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 05:14:23 +00:00
naruse 000f1c5b75 Add links about floating point. [ruby-core:31849]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-29 00:42:05 +00:00
usa 592d885caa * numeric.c (flo_cmp): typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-27 07:27:48 +00:00
nobu 7bfa1146e2 * numeric.c (flo_cmp): honor the result of infinite? method of the
other.  [ruby-core:31470]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-24 20:37:31 +00:00
mame b79e96ae62 * numeric.c (fix_divide): must not use rb_rational_new1 for coercion
because it returns an argument itself when canonical mode is set.
  [ruby-core:31279]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-15 12:55:23 +00:00
shyouhei ce9c952937 Merge branch 'mybranch' of git://github.com/orangea/ruby into trunk
Conflicts:
	ChangeLog

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-07 10:59:44 +00:00
akr 26202fba93 * numeric.c (rb_num2long): accept LONG_MAX < x < LONG_MAX+1 and
LONG_MIN-1 < x < LONG_MIN as well because they are converted
  into the valid range of long by truncation.
  (rb_num2ulong): accept ULONG_MAX < x < ULONG_MAX+1 and
  LONG_MIN-1 < x < LONG_MIN as well.
  (rb_num2ll): accept LLONG_MAX < x < LLONG_MAX+1 and
  LLONG_MIN-1 < x < LLONG_MIN.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-01 20:39:32 +00:00
akr 8bab1aff2c * numeric.c (rb_num2ulong): fix the lower limit for float.
[ruby-dev:41361]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-01 13:34:13 +00:00
drbrain 79aac05474 Clarification of what '*' matches. Patch by John Wells <john.wells at greatworx.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-04 21:22:47 +00:00
nobu eb5f96d70c * numeric.c (rb_num2ulong): explicit cast to suppress a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-22 08:14:02 +00:00
nobu e207a3912c * marshal.c (w_float): use dtoa directly instead of stripping
needless trailing .0.

* numeric.c (flo_to_s): reverted.  [ruby-dev:41341]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-21 03:26:00 +00:00
naruse 20eebb8542 * numeric.c (rb_num2ulong): use rb_big2ulong for data from
Bignum. Without this 32bit integer on 32bit environment
  can't converted into long.
  This fixes 1) and 2) of [ruby-dev:41289]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-19 09:22:59 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
marcandre 4afa9ed041 * array.c: Harmonize documentation, in particular regarding:
- methods returning enumerators
    - array methods and argument naming (array -> ary, an_array -> new_ary)
    - minor improvements, typo fixed and styling issues

  Other documentation errors fixed:
    - return value was self instead of a new array (or vice-versa) for
      Array#{pop,shift,permutation,repeated_permutation,keep_if}
    - Array#rindex was missing the form with a block.

* dir.c: ditto.

* enum.c: ditto. Modified Enumerable#reverse_each' documentation to clarify
  that #each will be finish before any element is yielded.

* error.c: ditto.

* gc.c: ditto.

* hash.c: ditto.

* io.c: ditto. IO#{codepoints,each_codepoint} fixed as per [ruby-core:23948]

* numeric.c: ditto.

* range.c: ditto.

* string.c: ditto.

* struct.c: ditto.

* vm_eval.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-13 05:49:55 +00:00
nobu cf32125cff * marshal.c (w_float): use minimal representation.
* numeric.c (ruby_dbl2cstr): split from rb_float_new.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-13 04:30:07 +00:00
nobu d80a859d98 * numeric.c (flo_to_s): fixed broken output including nuls.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-12 07:43:14 +00:00
nobu d2a68945e6 * numeric.c (flo_to_s): exponent needs 2 digits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-12 07:25:48 +00:00
nobu 16ea63ad69 * numeric.c (flo_to_s): fill lower zeros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-12 07:02:45 +00:00
nobu 07b314f07b * numeric.c (flo_to_s): make minimum string representation.
[ruby-core:30145]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-12 01:57:08 +00:00
marcandre 1dee5e34a3 * error.c: RDoc for subclasses of Exception. [ruby-core:28394]
* cont.c: ditto

* enumerator.c: ditto

* io.c: ditto

* math.c: ditto

* numeric.c: ditto

* proc.c: ditto

* re.c: ditto

* thread.c: ditto

* transcode.c: ditto. Thanks to Run Paint for some of the documentation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-08 04:50:09 +00:00
marcandre 478c3e080b * eval.c (make_exception, rb_obj_extend): Fix error messages in case of wrong
number of arguments

* file.c (rb_f_test, rb_file_s_umask): ditto

* numeric.c (int_chr, num_step): ditto

* process.c (rb_f_sleep): ditto

* re.c (rb_reg_initialize_m): ditto

* signal.c (rb_f_kill, sig_trap): ditto

* string.c (rb_str_aref_m, rb_str_aset_m, rb_str_count, rb_str_delete_bang,
  rb_str_slice_bang, rb_str_sub_bang, str_gsub): ditto

* proc.c (curry): rdoc fix

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-30 02:40:57 +00:00
usa 34f182f7b2 * numeric.c (fix_mul): the width of fixnum is same as long's on all
platforms.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-29 18:39:02 +00:00
akr 36ff32040e fix rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-11 13:59:34 +00:00
akr 1ad8521d44 update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-11 13:30:55 +00:00
matz b8acb1cc2d * numeric.c (flo_minus): RDoc update. a patch from red stun
in [ruby-core:27951]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-01 08:09:54 +00:00
nobu 41d8e49dc5 * numeric.c (flo_hash, int_chr): fixed type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-14 04:07:00 +00:00
naruse 9db87ea5b9 * include/ruby/defines.h (INFINITY): this is float.
* include/ruby/defines.h (NAN): ditto.

* numericc.c (rb_infinity): change content as float.

* numericc.c (rb_nan): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-30 10:44:02 +00:00
naruse 7ed0640ffb Add Float::INFINITY and Float::NAN.
* numeric.c (Init_Numeric): Add Float::INFINITY and Float::NAN.
  [ruby-dev:1657] [ruby-dev:4760] [ruby-list:7023] [ruby-list:46690]
  [ruby-core:26632] [ruby-talk:41352] [ruby-talk:203333]

* include/ruby/defines.h (INFINITY): defined.

* include/ruby/defines.h (NAN): defined.

* include/ruby/util.h (ruby_div0): removed.

* numeric.c (fix_pow): use INFINITY and NAN instead of ruby_div0(1.0).

* marshal.c (r_object0): ditto.

* bignum.c (big_fdiv): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-29 07:05:39 +00:00
usa dd00d45244 * numeric.c (flo_eq): supress a warning on VC++ for x64.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-08 14:41:17 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
nobu 31b7ae00c0 * include/ruby/st.h (st_hash_func): use st_index_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-08 13:10:04 +00:00
nobu ef2c92ddf0 * numeric.c (flo_quo, int_round): added rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-05 06:41:40 +00:00
nobu 0cf0b0eed4 * numeric.c (round): added declaration. [ruby-dev:39222]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-04 11:40:58 +00:00
nobu 84255e0485 * vm_method.c (rb_remove_method_id): exported.
* numeric.c (num_sadded): fix for non-ascii method name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-27 09:31:11 +00:00
tadf 02a7cbec82 * numeric.c (flo_pow,fix_pow): may return complex number.
* bignum.c (rb_big_pow): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-16 23:03:45 +00:00
matz 9166dd9ec7 * numeric.c (num_imaginary): num#i to return imaginary counterpart
of the given numeric.

* complex.c (Init_Complex): undef #i for complex numbers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-16 22:28:48 +00:00
ko1 8e8e34319b * insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h: check
definition of (classes)#=== for case/when optimization.
  Fix Bug #1376 [ruby-core:23190].
* string.c (Init_String), bignum.c (Init_Bignum),
  numeric.c (Init_Numeric): define String#===, Symbol#===,
  Bignum#===, Fixnum#===, Float#=== as same as (classes)#==.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-12 05:55:06 +00:00
nobu 8dfd78fc1c * numeric.c (num_divmod): fixed rdoc. [ruby-core:24862]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-11 12:42:53 +00:00
matz 45cd729f17 * numeric.c (flo_hash): normalize -0.0 to 0.0. [ruby-core:24577]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-03 05:15:54 +00:00
nobu e07cb859cc * suppressed shorten-64-to-32 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 08:05:32 +00:00
tadf fff1183ffe * numeric.c (fix_divide): added an entry to rational.
* rational.c (rb_rational_reciprocal): added.

	* complex.c (f_reciprocal): added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-12 11:46:40 +00:00
matz a82c5ee48b * numeric.c (dbl2ival): should raise FloatDomainError on Infinity
and NaN as 1.8 does.  [ruby-dev:38726]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-04 00:46:14 +00:00
tadf 426afe1e67 trivial changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-28 00:22:41 +00:00
tadf b2fb759624 * complex.c: revised rdoc.
* rational.c: ditto.

	* numeric.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-27 07:46:57 +00:00
matz 8a5ffe48e5 * numeric.c (int_chr): use default_internal encoding as default
destination encoding if set.  [ruby-dev:38717]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-26 18:18:12 +00:00
tadf d82ed7e2c6 * numeric.c (num_div): don't use num_floor which is actually
flo_floor.

	* numeric.c (num_modulo): don't call '%'.

	* numeric.c (num_divmod): use num_modulo.

	* numeric.c: defined '%'.

	* rational.c (nurat_idiv,nurat_mod,nurat_divmod,nurat_rem): removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-20 12:37:13 +00:00
tadf a05fd849a1 * complex.c: edited rdoc.
* numeric.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-20 11:29:21 +00:00
tadf 40d6a7527e * complex.c: edited rdoc.
* rational.c: ditto.

	* numeric.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-19 23:57:34 +00:00
tadf ab7baebb6d * complex.c: edited rdoc.
* rational.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-19 21:57:51 +00:00
tadf d11b549104 * numeric.c: edited rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-19 14:44:03 +00:00
tadf f86ad72d2a due to conflict
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-19 13:37:04 +00:00
matz cdba56b38a * numeric.c (flo_cmp): should always return nil for NaN.
* numeric.c (flo_cmp): handle infinite value specially using
  infinite? method internally.  [ruby-dev:38681]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-19 08:19:14 +00:00
tadf 5134783cde * numeric.c (*_numerator,*_denominator): moved to rational.c.
* rational.c (*_numerator,*_denominator): moved from numeric.c.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-19 00:31:08 +00:00
tadf 1fda5e1a3f * numeric.c ( num_numerator, num_denominator): use
to_r [ruby-core:23910].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-18 11:33:52 +00:00
matz 7fc9c4a4a0 * numeric.c (flo_cmp): Infinity is greater than any bignum
number.  [ruby-dev:38672]

* bignum.c (rb_big_cmp): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-17 17:05:31 +00:00
tadf b6849b2502 * bignum.c (rb_big_fdiv): checks whether the given second argument
can be converted to float properly.

	* numeric.c (fix_fdiv): calls rb_big_fdiv when the given second
	  argument is a bignum.

	* rational.c (nurat_fdiv): should calculate Float(x/y), not
	  Float(x)/Float(y).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-17 12:55:16 +00:00
nobu 8e86bd59c0 * common.mk (bignum.o, numeric.o): depend on util.h.
* bignum.c, marshal.c: fixed types.

* numeric.c (infinite_value): use ruby_div0.

* include/ruby/util.h (ruby_div0): moved from marshal.c.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-26 04:58:15 +00:00
nobu 060f433f48 * include/ruby/ruby.h (rb_long2int, RARRAY_LENINT): check long to
cast to int.  [ruby-dev:38508]

* struct.c, vm_eval.c, vm_insnhelper.c: use RARRAY_LENINT.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-20 16:43:41 +00:00
nobu 8ebd0d4320 * numeric.c (flo_to_s): reduce fragments if no precision lost.
c.f. [ruby-core:23075]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-06 16:08:23 +00:00
nobu a3a88c6bcd * file.c (sys_fail2, rb_file_s_readlink, BUFCHECK, rmext),
(rb_file_s_basename): get rid of overflow.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-06 07:38:52 +00:00
nobu 1b71f8a53b * numeric.c (int_chr): checsk overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-06 06:11:57 +00:00
nobu d1abc53721 * array.c, bignum.c, dln.c, error.c, gc.c, io.c, marshal.c,
numeric.c, pack.c, strftime.c, string.c, thread.c, transcode.c,
  transcode_data.h, util.c, variable.c, vm_dump.c,
  include/ruby/encoding.h, missing/crypt.c, missing/vsnprintf.c:
  suppress VC type warnings.  [ruby-core:22726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-12 09:16:15 +00:00
nobu 080525aa68 * marshal.c (div0), numeric.c (infinite_value): new functions to
get rid of VC divion by 0 warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-12 09:09:15 +00:00
nobu 2e54fe9d4d * array.c, bignum.c, gc.c, numeric.c, string.c, util.c, insns.def,
missing/crypt.c, missing/vsnprintf.c, : suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-10 05:43:14 +00:00
nobu 9b52ae2e64 * numeric.c (flo_to_s): keeps enough precision for round trip.
[ruby-core:22325]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-05 09:36:39 +00:00
usa c691d55bcd * numeric.c (flo_eq, flo_gt, flo_ge, flo_lt, flo_le, flo_eql): revert
isnan() checks for VC++6.

	* insns.def (opt_lt, opt_gt): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-27 05:42:06 +00:00
matz 60e8b398cd * numeric.c (flo_eq): remove unnecessary NaN check using isnan().
comparison regarding NaN is false anyway.

* numeric.c (flo_gt, flo_ge, flo_lt, flo_le, flo_eql): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-23 17:15:17 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
nobu 367de8b97b * numeric.c (ruby_float_step): extracted from num_step().
* range.c (range_step): uses ruby_float_step() for float range.
  [ruby-dev:37691]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-04 02:58:45 +00:00
tadf 292d6ee99f * numeric.c: Infinity.numerator returns self. [experimental]
* numeric.c: Infinity.denominator returns 1. [experimental]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-29 12:23:55 +00:00
tadf 5d7f9f1721 arrangement
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-29 11:57:06 +00:00
akr a550f2992b * numeric.c (int_ord): Integer#ord implemented.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-22 12:32:11 +00:00
nobu 9f3b77e435 * configure.in (mingw): no longer uses snprintf and vsnprintf of
msvcrt.

* win32/win32.c (rb_w32_vsnprintf, rb_w32_snprintf): removed.

* win32/Makefile.sub (config.h): vsnprintf exists in VC7 or later.

* win32/mkexports.rb (Exports#initialize): aliases
  rb_w32_vsnprintf and rb_w32_snprintf for binary compatibility.

* sprintf.c (rb_str_format): uses snprintf instead of sprintf.

* numeric.c (flo_to_s, rb_num2long, rb_num2ll): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-22 03:05:20 +00:00
matz 90add5db45 * numeric.c (flodivmod): floating point division should raise
ZeroDivisionError as integer division. [incompatible]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-27 16:01:54 +00:00
matz 012fee9476 * numeric.c (num_step): treat infinite step specially.
[ruby-dev:37157] fix: #781.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-24 18:40:07 +00:00