Commit graph

171 commits

Author SHA1 Message Date
knu
3b6affb067 * numeric.c (int_pow, fix_mul): Avoid optimization bugs of
clang.  Submitted by Wataru Kimura [Bug #6796].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@36546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-27 04:12:08 +00:00
knu
d040bf7593 Backport r23730; fixes #2462.
* 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/branches/ruby_1_8@32573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-17 08:53:08 +00:00
usa
40397db9da 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
2011-04-18 01:12:36 +00:00
usa
21be8efab0 * numeric.c (Init_Numeric): fixed a potential bug when using bccwin32
ruby with Microsoft's dll. [ruby-core:33503]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@29999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-01 13:06:12 +00:00
marcandre
ea1b7a9577 * time.c: rdoc fix for <=>
* array.c: ditto

* bignum.c: ditto

* compar.c: ditto

* file.c: ditto

* numeric.c: ditto

* string.c: rdoc fix for <=> and casecmp

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-28 05:01:29 +00:00
nobu
3f0d0b9398 * *.[chy]: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-22 01:00:18 +00:00
marcandre
28d641911b * numeric.c: Fix doc for #remainder [ruby-core:18796]
* ext/bigdecimal/bigdecimal.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 17:46:59 +00:00
nobu
643462810e * numeric.c (round): added declaration. [ruby-dev:39222]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@24750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-04 11:40:58 +00:00
nobu
6c54c1f8de * numeric.c (num_divmod): fixed rdoc. [ruby-core:24862]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@24498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-11 12:42:53 +00:00
knu
e8b0f17319 * array.c (ary_resize_capa): Remove an unused function.
* array.c, bignum.c, dir.c, enumerator.c, gc.c, io.c, numeric.c,
  object.c, re.c, string.c, struct.c: Mixing two styles is not a
  good thing.  Stick with the K&R style in 1.8.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-23 12:07:23 +00:00
nobu
19ad459b63 * 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@21298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-04 02:58:45 +00:00
matz
98183a08c7 * dln.c: newer BeOS support. a patch from Pete Goodeve
<pete.goodeve at computer.org> in [ruby-core:18712].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@19424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-19 00:32:22 +00:00
usa
61a2d6baf3 Sat Jul 19 00:27:58 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* 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@18129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-18 15:41:47 +00:00
usa
b4e3812104 * numeric.c (check_uint, rb_num2uint, rb_fix2uint): strict check.
fixed [ruby-dev:33683]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@18100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-17 01:32:58 +00:00
usa
972769ca8e * numeric.c (check_uint): sorry, backport misstake.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-04 11:21:35 +00:00
usa
5b3dd029bd * numeric.c (check_uint, rb_num2uint, rb_fix2uint): proper check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-04 08:54:47 +00:00
usa
f15ac284c5 * numeric.c (rb_fix2uint): typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-03 20:05:54 +00:00
usa
654a54a664 * numeric.c (check_uint, rb_num2uint): also needs checking negative
value. see [ruby-dev:33683]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-03 17:38:41 +00:00
akr
8f521e4af9 forgot to commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-30 16:04:04 +00:00
nobu
1378795e08 * suppress warnings with -Wwrite-string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00
knu
78287c3d2e * numeric.c (flo_divmod): Revert the behavior change; do not
suppress an exception when div is NaN or Inf. [ruby-dev:34857]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 10:49:42 +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