Commit graph

158 commits

Author SHA1 Message Date
shyouhei
700acefade merge revision(s) 23730:
* 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
Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@34000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-10 12:17:27 +00:00
shyouhei
4e5325fe1f merge revision(s) 31302:
backported r31286 from trunk

	* 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/branches/ruby_1_8@31302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@31663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-20 22:29:05 +00:00
shyouhei
cfa3a72cc2 merge revision(s) 24750:
* numeric.c (round): added declaration.  [ruby-dev:39222]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@25811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-17 06:31:41 +00:00
shyouhei
6cec674877 merge revision(s) 21298:
* 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/branches/ruby_1_8_7@22528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 12:43:42 +00:00
shyouhei
3fcb394972 merge revision(s) 18100,18129:
* numeric.c (check_uint, rb_num2uint, rb_fix2uint): strict check.
	  fixed [ruby-dev:33683]
	* numeric.c (check_uint, rb_num2uint, rb_fix2uint): fixed wrong check
	  about 64bit positive value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@18331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-04 04:36:00 +00:00
shyouhei
ed2c44bbfe merge revision(s) 17749:17752:
* numeric.c (num_coerce): call rb_Float(x) first.  don't depend on
	  evaluation order of function arguments.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@17813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 10:05:01 +00:00
knu
f072d4e34a Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 11:44:49 +00:00
knu
b0278ac764 Merge from ruby_1_8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 10:50:15 +00:00
knu
125d830eb8 * array.c (rb_ary_collect_bang, rb_ary_select): Return an
enumerator if no block is given.

* dir.c (dir_each, dir_foreach): Return an enumerator if no block
  is given.

* enum.c (enum_partition, enum_sort_by): Ditto.

* gc.c (os_each_obj): Ditto.

* hash.c (rb_hash_delete_if, rb_hash_reject_bang, rb_hash_select,
  rb_hash_each_value, rb_hash_each_key, rb_hash_each_pair,
  env_each_key, env_each_value, env_each, env_each_pair,
  env_reject_bang, env_delete_if, env_select): Ditto.

* numeric.c (num_step, int_upto, int_downto, int_dotimes): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 08:57:23 +00:00
nobu
163b436fad * numeric.c (fix_coerce): try conversion before type check.
[ruby-core:15838]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-11 10:48:12 +00:00
akr
89dac0bc8c * numeric.c (int_odd_p): new method Integer#odd?.
(int_even_p): new method Integer#even?.
  (int_pred): new method Integer#pred.
  (fix_odd_p): new method Fixnum#odd?.
  (fix_even_p): new method Fixnum#even?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@14111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-05 09:12:58 +00:00
nobu
349377aab4 * numeric.c (round): fallback definition.
* numeric.c (flo_divmod, flo_round): use round() always.
  [ruby-dev:32269]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 16:34:45 +00:00
nobu
4e0ac23588 * numeric.c (flodivmod): work around for inifinity.
* numeric.c (flo_divmod): work around for platforms have no round().
  [ruby-dev:32247]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 07:33:09 +00:00
akr
6bc16a1198 * numeric.c (numeric.c): Integer#ord implemented. [ruby-dev:32206]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 05:00:03 +00:00
shyouhei
9bb7c21970 * numeric.c (flo_divmod): round to the nearest integer. [ ruby-Bugs-14540 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-12 18:41:31 +00:00
nobu
93f00244c5 * numeric.c (fix_pow): returns 1.0 for 0**0.0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-26 08:14:14 +00:00
nobu
92d83c9354 * numeric.c (fix_pow): returns infinity for 0**-1. [ruby-dev:32084]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-26 08:01:41 +00:00
nobu
9bf8a37572 * bignum.c (rb_big_lshift, rb_big_rshift): separated functions
to get rid of infinite recursion.  fixed calculation in edge
  cases.  [ruby-dev:31244]

* numeric.c (rb_fix_lshift, rb_fix_rshift): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-19 05:38:48 +00:00
matz
217db90e87 * numeric.c (fix_pow): integer power calculation: 0**n => 0,
1**n => 1, -1**n => 1 (n: even) / -1 (n: odd).

* test/ruby/test_fixnum.rb (TestFixnum::test_pow): update test
  suite.  pow(-3, 2^64) gives NaN when pow(3, 2^64) gives Inf.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-16 15:56:16 +00:00
matz
bd3af05e48 * numeric.c (fix_pow): 0**2 should not raise floating point
exception.  [ruby-dev:31216]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-13 17:53:10 +00:00
matz
98b7080d2a * numeric.c (int_pow): wrong overflow detection. [ruby-dev:31215]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-13 17:27:40 +00:00
matz
356d61050c * numeric.c (int_pow): wrong overflow detection. [ruby-dev:31213]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-13 16:46:39 +00:00
usa
42b4e02760 * numeric.c (int_pow): fix previous nubu's commit.
* test/ruby/test_fixnum.rb: new test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 07:45:02 +00:00
nobu
890d25d46f * numeric.c (int_pow): even number multiplication never be negative.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 06:56:10 +00:00
nobu
ce6fd792ad * numeric.c: purged trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-09 04:11:41 +00:00
nobu
8624d6b3f6 * bignum.c (Init_Bignum), numeric.c (Init_Numeric): added fdiv as
aliases of quo.  [ruby-dev:30771]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-09 03:28:08 +00:00
nobu
587035c080 * numeric.c (int_pow): calculate power in Fixnum as possible.
[ruby-dev:30726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-05-09 03:16:16 +00:00
knu
38c8efbe2d * numeric.c (fix_cmp, fix_equal): Remove FIX2LONG() to optimize.
suggested in
  http://t-a-w.blogspot.com/2007/02/making-ruby-faster.html.
  [ruby-talk:240223]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 04:04:14 +00:00
ryan
c2f9106b1a Minor rdoc fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-24 20:47:57 +00:00
matz
b2b33db355 * numeric.c (fix_plus): addition in Fixnum will never overflow
long.  a patch from Ondrej Bilka <neleai at seznam.cz>.
  [ruby-core:08794]

* numeric.c (fix_minus): ditto.

* bignum.c (rb_big_pow): eagerly truncate resulting bignum.
  [ruby-core:08794]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-07 16:35:59 +00:00
nobu
dfac39ff8d * numeric.c (flo_hash): improve collision. fixed: [ruby-dev:29352]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-04 20:57:02 +00:00
akr
53cec657a1 * common.mk, configure.in, defines.h, eval.c, gc.c, main.c,
numeric.c, ruby.h, ia64.s: backport IA64 HP-UX support.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-01 18:47:11 +00:00
matz
9466848db3 * numeric.c (num_div): use floor rather than rb_Integer().
[ruby-dev:28589]

* numeric.c (flo_divmod): the first element of Float#divmod should
  be an integer. [ruby-dev:28589]

* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.

* util.c (ruby_strtod): fixed wrong conversion.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-05-01 03:46:47 +00:00
ocean
dbf7e59c68 * numeric.c (fix_to_s): removed workaround for radix 2. Historically,
rb_fix2str can only handle radix 8, 10, 16. (Rev1.37) But for now,
  it can handle radix 2..36. [ruby-Bugs#3438]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-02-05 12:09:31 +00:00
ocean
1939b48f8d * numeric.c (fix_to_s): (2**32).to_s(2) fails with exception where
sizeof(int) == 4 < sizeof(long). [ruby-core:7300]

  I think the function name of rb_int2big is quite misleading.
  This should be "rb_long2big".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-02-04 06:58:43 +00:00
matz
2c0701f658 * ext/readline/readline.c (readline_readline): type check.
[ruby-core:6089]

* numeric.c (fix_rshift): RDoc fix.  [ruby-core:6351]

* util.h (strtod): add #undef for platforms defines strtod()
  macro.   [ruby-dev:27563]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-30 18:20:54 +00:00
nobu
e594bf57d8 * class.c (rb_mod_init_copy, rb_class_init_copy), file.c (rb_stat_init_copy),
numeric.c (num_init_copy), object.c (rb_obj_init_copy, Init_Object),
  re.c (match_init_copy, rb_reg_init_copy), time.c (time_init_copy):
  undocumented.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-28 14:42:46 +00:00
matz
210bf4dc6e * bignum.c (rb_big_eq): reduce isnan(). [ruby-dev:26600]
* numeric.c (flo_eq, flo_gt, flo_ge, flo_lt, flo_le): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-07-22 13:04:25 +00:00
matz
c33063f42d * numeric.c (fix_pow): support Fixnum ** Float case directly
without coercing.  [ruby-talk:142697] [ruby-talk:143054]

* ruby.c (require_libraries): caused SEGV when continuation jumped
  in to the required library code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-05-24 14:52:05 +00:00
ocean
c3af8e7c3b * numeric.c (flo_plus): small typo fix. [ruby-core:4636]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-05-10 01:40:49 +00:00
matz
88d5dcc8de * exception error messages updated. [ruby-core:04497]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-02-28 02:45:23 +00:00
ocean
cfa20a2a86 * numeric.c (Init_Numeric): turn off floating point exceptions
on bcc32. "1e300".to_f had crashed by overflow.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-01-11 00:46:35 +00:00
matz
db8a49614f * process.c (proc_getpgrp): prohibit for $SAFE=2.
[ruby-dev:24899]

* process.c (get_pid): ditto.  [ruby-dev:24904]

* process.c (get_ppid): ditto.

* array.c (rb_ary_delete): defer rb_ary_modify() until actual
  modification.  [ruby-dev:24901]

* parse.y (newline_node): should not use FL_SET. [ruby-dev:24874]

* parse.y (string_content): should not use FL_UNSET.

* node.h (NODE_NEWLINE): remove unused bit to utilize flag field
  in nodes.

* string.c (rb_str_splice): move rb_str_modify() after
  StringValue(), which may alter the receiver.  [ruby-dev:24878]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-18 03:47:14 +00:00
matz
73deb73392 * numeric.c (flo_divmod): protect float values from GC by
assignment to local variables.  [ruby-dev:24873]

* string.c (str_mod_check): frozen check should be separated.
  [ruby-core:3742]

* array.c (rb_ary_update): pedantic check to detect
  rb_ary_to_ary() to modify the receiver.  [ruby-dev:24861]

* string.c (rb_str_justify): typo fixed.  [ruby-dev:24851]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-16 14:54:49 +00:00
matz
ece87af00c * string.c (RESIZE_CAPA): check string attribute before modifying
capacity member of string structure.  [ruby-dev:24594]

* ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain
  performance.  [ruby-talk:117701]

* sprintf.c (rb_f_sprintf): raise ArgumentError for extra
  arguments, unless (digit)$ style used.

* ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain
  performance.  [ruby-talk:117701]

* sprintf.c (rb_f_sprintf): raise ArgumentError for extra
  arguments, unless (digit)$ style used.

* eval.c (frame_free): Guy Decoux solved the leak problem.
  Thanks.  [ruby-core:03549]

* ext/zlib/zlib.c (zstream_append_input): clear klass for z->input
  to avoid potential vulnerability.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-27 02:46:54 +00:00
ocean
703f913426 * array.c, enum.c, pack.c: rdoc patch from Johan Holmberg
<holmberg@iar.se> [ruby-core:3132] [ruby-core:3136]

* numeric.c: rdoc patch.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-07-09 13:38:34 +00:00
matz
36eb460780 * eval.c (rb_mod_freeze): prepare string representation before
freezing. [ruby-talk:103646]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-06-16 14:21:34 +00:00
matz
79c7044582 * io.c (rb_io_gets_m): set lastline ($_) even when read line is
nil.  [ruby-dev:23663]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-06-04 09:56:25 +00:00
matz
4c36359dea * numeric.c (flo_eq): alway check if operands are NaN.
[ruby-list:39685]

* lib/cgi/session.rb: use LOCK_SH to read, and a few other
  improvements.  [ruby-core:02328]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-05-20 04:28:36 +00:00
ocean
36b02b16a1 * numeric.c (flo_to_s): p 0.0 should be '0.0' not '0.0e+00'.
* numeric.c (flo_to_s): the number of significand is correctly handled,
  there is assumption that DBL_DIG == 15 though.
  (p 0.00000000000000000001 was '9.999999999999999e-21', now is
  '1.0e-20')


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-05-17 07:14:45 +00:00