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

764 Коммитов

Автор SHA1 Сообщение Дата
akr 27f9556de9 {Fixnum,Bignum}#fdiv is unified into Integer.
* numeric.c (int_fdiv): {Fixnum,Bignum}#fdiv is unified into
  Integer.

* bignum.c (rb_big_fdiv): Don't define Bignum#fdiv.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 04:20:56 +00:00
akr 8a2df1ce3f {Fixnum,Bignum}#** is unified into Integer.
* numeric.c (rb_int_pow): {Fixnum,Bignum}#** is unified into
  Integer.

* bignum.c (rb_big_pow): Don't define Bignum#**.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 03:59:02 +00:00
akr d73b431e50 Rename fix_rev and rb_big_neg to fix_comp and rb_big_comp.
* bignum.c (rb_big_comp): Renamed from rb_big_neg.

* numeric.c (fix_comp): Renamed from fix_rev.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 03:30:53 +00:00
akr 10fb4e151d {Fixnum,Bignum}#~ is unified into Integer.
* numeric.c (int_comp): {Fixnum,Bignum}#~ is unified into
  Integer.

* bignum.c (rb_big_neg): Don't define Bignum#~.

* internal.h (rb_big_neg): Declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 03:27:20 +00:00
akr b296cacb12 {Fixnum,Bignum}#& is unified into Integer.
* numeric.c (int_and): {Fixnum,Bignum}#& is unified into
  Integer.

* bignum.c (rb_big_and): Don't define Bignum#|.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 03:08:53 +00:00
akr 44af023d44 {Fixnum,Bignum}#| is unified into Integer.
* numeric.c (int_or): {Fixnum,Bignum}#| is unified into
  Integer.

* bignum.c (rb_big_or): Don't define Bignum#|.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 02:54:14 +00:00
akr f949a95dab {Fixnum,Bignum}#^ is unified into Integer.
* numeric.c (int_xor): {Fixnum,Bignum}#^ is unified into
  Integer.

* bignum.c (rb_big_xor): Don't define Bignum#^.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-27 15:35:23 +00:00
akr c71e02bd07 [Doc] Add Document-method: directives.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-27 13:05:09 +00:00
kazu b530f58647 Update rdoc of Integer#[] (fix -> int)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-27 12:59:59 +00:00
akr 02107a91c8 [DOC] move rdoc comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-27 12:46:46 +00:00
akr d5a7299bca {Fixnum,Bignum}#[] is unified into Integer.
* numeric.c (int_aref): {Fixnum,Bignum}#[] is unified into
  Integer.

* bignum.c (rb_big_aref): Don't define Bignum#<<.

* internal.h (rb_big_aref): Declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-27 11:56:03 +00:00
akr 68c661b8e5 [DOC] update Integer#<< doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-26 12:29:41 +00:00
akr 06ca50338b {Fixnum,Bignum}#<< is unified into Integer.
* numeric.c (rb_int_lshift): {Fixnum,Bignum}#<< is unified into
  Integer.

* bignum.c (rb_big_lshift): Don't define Bignum#<<.

* internal.h (rb_big_lshift): Declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-26 12:23:05 +00:00
akr 69fbb21c12 {Fixnum,Bignum}#>> is unified into Integer.
* numeric.c (rb_int_rshift): {Fixnum,Bignum}#>> is unified into
  Integer.

* bignum.c (rb_big_rshift): Don't define Bignum#>>.

* internal.h (rb_big_rshift): Declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-26 12:09:40 +00:00
akr 8f045eddb2 {Fixnum,Bignum}#size is unified into Integer.
* numeric.c (int_size): {Fixnum,Bignum}#size is unified into Integer.

* bignum.c (rb_big_size_m): Don't define Bignum#size.

* internal.h (rb_big_size_m): Declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-26 11:47:14 +00:00
akr bcc1796983 {Fixnum,Bignum}#bit_length is unified into Integer.
* numeric.c (rb_int_bit_length): {Fixnum,Bignum}#bit_length is
  unified into Integer.

* bignum.c (rb_big_bit_length): Don't define Bignum#bit_length.

* internal.h (rb_big_bit_length): Declared.

--This iine, and those below, will be ignored--

M    ChangeLog
M    bignum.c
M    internal.h
M    numeric.c


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-26 11:17:37 +00:00
akr 9368d7515b * numeric.c (int_abs): Integer#{abs,magnitude} moved from Fixnum and Bignum.
* internal.h (rb_big_abs): Declared.

* bignum.c (rb_big_abs): Don't define Bignum#{abs,magnitude}.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-26 10:59:27 +00:00
nobu 0a38e38aea numeric.c: numeric ndigits
* numeric.c (num_floor, num_ceil, num_truncate): add an optional
  parameter, digits, as well as Numeric#round.  [Feature #12245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-18 03:57:34 +00:00
nobu fe96a2495c numeric.c: flo_truncate
* numeric.c (flo_truncate): add an optional parameter, digits, as
  well as Float#round.  [Feature #12245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-18 03:56:33 +00:00
nobu 39f31b8c87 numeric.c: int_truncate
* numeric.c (int_truncate): add an optional parameter, digits, as
  well as Integer#round.  [Feature #12245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-18 03:55:33 +00:00
nobu ae4eb682db numeric.c: update doc [ci skip]
* numeric.c (int_to_i): [DOC] floor and ceil are no longer
  synonyms.  [Feature #12245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-18 02:38:37 +00:00
nobu c258535186 numeric.c: flo_ceil
* numeric.c (flo_ceil): add an optional parameter, digits, as
  well as Float#round.  [Feature #12245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 06:56:36 +00:00
nobu d56b277684 numeric.c: flo_floor
* numeric.c (flo_floor): add an optional parameter, digits, as
  well as Integer#floor.  [Feature #12245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 06:54:38 +00:00
nobu a1542d33ca numeric.c: int_ceil
* numeric.c (int_ceil): add an optional parameter, digits, as
  well as Integer#round.  [Feature #12245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 06:50:24 +00:00
nobu 15558a8f57 numeric.c: int_floor
* numeric.c (int_floor): add an optional parameter, digits, as
  well as Integer#round.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 06:47:55 +00:00
nobu 1ea1d2e4a7 numeric.c: int_round_zero_p
* bignum.c (rb_big_size): add wrapper function of BIGSIZE and
  rename the method funtion with _m suffix.
* numeric.c (int_round_zero_p): extracted from rb_int_round.
  optimize for Bignum, and convert VALUE returned by Numeric#size
  to long.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 05:12:01 +00:00
nobu aaf0f51f46 numeric.c: float_invariant_round
* numeric.c (float_invariant_round): extracted from flo_round to
  be optimizer-friendly, e.g., tail-call optimization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13 02:41:24 +00:00
nobu b4c0aac4c8 numeric.c: dbl2ival no longer rounds
* numeric.c (flodivmod): round division if it is a finite number
  and module is required.
* numeric.c (dbl2ival): do not round here.
* numeric.c (flo_ceil): use dbl2ival.
* numeric.c (flo_round): round explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-03 00:34:31 +00:00
nobu 95813d475f numeric.c: move declaration [ci skip]
* numeric.c (fix_lshift, fix_rshift, flo_truncate): move forward
  declaration to the top.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-02 22:38:44 +00:00
nobu 9a686593c7 numeric.c: prefer rb_check_arity
* numeric.c (flo_round, int_to_s, int_round): use rb_check_arity
  instead of rb_scan_args for a simple optional argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-02 06:33:26 +00:00
kazu 0a41425ad4 * numeric.c (int_pos_p): fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-28 12:25:41 +00:00
nobu 23e5b482ca numeric.c: rb_int2str
* numeric.c (rb_int2str): conversion function to String for
  generic Integer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-26 01:55:14 +00:00
nobu e9dc649d66 numeric.c: rb_int_round
* numeric.c (rb_int_round): rounding function for generic
  Integers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-26 01:54:50 +00:00
nobu 79b209f19a numeric.c: basic arithmetic
* numeric.c (rb_int_{uminus,plus,minus,mul,idiv,modulo}): basic
  arithmetic functions for generic Integers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-26 01:54:16 +00:00
nobu ed47a0ec80 numeric.c: Fixnum predicts
* numeric.c (FIXNUM_{POSITIVE,NEGATIVE,ZERO}_P): predict macros
  only for Fixnum.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-26 01:52:00 +00:00
naruse 51c4ffa45b * internal.h (rb_fix_divmod_fix): like r54213, use FIX2NUM only if
x == FIXNUM_MIN && y == -1. This must be a rare case and it is
  expected compiler to handle well.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 13:36:03 +00:00
naruse 148f1b9d57 * internal.h (DLONG): defined if long is 32bit (and LONG_LONG is 64bit;
but LONG_LONG is always defined as 64bit), or there's int128_t.

* internal.h (DL2NUM): defined if DLONG is defined.

* internal.h (rb_fix_mul_fix): defined for `Fixnum * Fixnum`.

* insns.def (opt_mul): use rb_fix_mul_fix().

* numeric.c (fix_mul): ditto.

* time.c (mul): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-20 11:10:43 +00:00
nobu be05c5798f numeric.c: optimize Fixnum<->Bignum comparisons
* numeric.c (fix_gt, fix_ge, fix_lt, fix_le): optimize comparisons
  Fixnum against Bignum by rb_big_cmp in inversed order without
  new Bignum instance.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-20 09:53:50 +00:00
nobu 448b4eb117 fix r54193
* numeric.c (fix_cmp): invert the result as the comarison is
  inverted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19 12:53:36 +00:00
naruse b01312ab97 * numeric.c (fix_cmp): use rb_big_cmp if x is Fixnum and y is Bignum.
rb_big_cmp handles such case smartly with big_norm.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19 10:06:57 +00:00
mrkn 5a213ee2e2 * numeric.c (int_to_f): raise NotImplementedError when a receiver
class is unknown.

* test/-ext-/integer/test_my_integer.rb (test_my_integer_to_f): modify
  a test for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19 09:43:35 +00:00
mrkn 81f65a9e05 * bignum.c (Bignum#<=>): remove it because they are unified with
Integer#<=>.

* numeric.c (Integer#<=>, Fixnum#<=>): move <=> method from Fixnum to
  Integer.

* numeric.c (int_cmp): add this method for Integer#<=>.

* test/-ext-/integer/test_my_integer.rb (test_my_integer_cmp): add a
  test to examine Integer#<=> for unknown subclasses.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19 09:28:12 +00:00
mrkn 0d076fe4b3 * bignum.c (rb_big_to_f, Bignum#to_f): removed them because they are
unified with int_to_f and Integer#to_f.

* numeric.c (int_to_f): treat Bignum values directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 15:02:45 +00:00
mrkn b60a7b43fe * numeric.c (int_to_f, fix_to_f): rename fix_to_f to int_to_f, and add
treatment for subclasses which don't have definitions of to_f method.

* numeric.c (Integer#to_f, Fixnum#to_f): move to_f method from Fixnum
  to Integer.

* ext/-test-/integer/my_integer.rb: define helper class for testing
  to_f method for a subclass of Integer.

* ext/-test-/integer/extconf.rb: ditto.

* ext/-test-/integer/init.c: ditto.

* test/-ext-/integer/test_my_integer.rb: examine to_f method for a
  subclass of Integer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 14:52:46 +00:00
mrkn 18d114eff2 * bignum.c (Bignum#eql?): remove its definition because it is unified
with Numeric#eql?.

* numeric.c (num_eql): treat Bignum values directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 13:11:09 +00:00
mrkn ad0b5ebc50 * bignum.c (rb_big_to_s, Bignum#to_s): remove its definition because
it is unified with Integer#to_s.

* numeric.c (int_to_s): treat Bignum values directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 12:57:40 +00:00
mrkn a22ff208e5 * numeric.c (int_to_s): Move from flo_to_s.
* numeric.c (Integer#to_s): Move from Fixnum#to_s.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 12:33:28 +00:00
mrkn 2169bea82e * numeric.c (fix_zero_p, fix_even_p, fix_odd_p): remove needless
functions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 17:17:08 +00:00
mrkn 0a607bc8f8 * numeric.c (int_even_p): treat Fixnum and Bignum values directly.
I forgot include this commit in the previous one.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 17:15:33 +00:00
mrkn aa1ea07d37 * bignum.c (Bignum#even?, Bignum#odd?): remove definitions
because they are unified with Integer#even? and Integer#odd?.

* numeric.c (Fixnum#zero?, Fixnum#even?, Fixnum#odd?): remove
  definitions because they are unified with Numeric#zero?,
  Integer#even?, and Integer#odd?.

* numeric.c (num_zero_p, int_even_p, int_odd_p): treat Fixnum and
  Bignum values directly.

* test/ruby/test_integer.rb (test_odd_p_even_p): remove meaningless
  test case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 17:11:42 +00:00
mame 64a76ee8a8 * numeric.c (num_step): use rb_equal for zero check. rb_num_coerce_cmp
created an object which caused extra overhead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 15:18:59 +00:00
akr fa153d7435 * enum.c (enum_inject): Implement the specialized code for sum of
integers including Bignums.

* internal.h (rb_fix_plus): Declared to be usable from enum_inject.

* numeric.c (rb_fix_plus): Defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17 09:50:19 +00:00
naruse fcadcd3e68 * numeric.c (fix2str): improve r54092 like rb_int2big().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-14 04:41:16 +00:00
nobu 05d916415f numeric.c: fix edge case
* numeric.c (rb_fix2str): fix edge case, accidentally generated
  wrong Fixnum from LONG_MIN.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-13 00:15:48 +00:00
naruse 1b49df0b3d * intern.h (rb_divmod): assume compilers `/` and `%` comply C99
and reduce branching. If a compiler doesn't comply, add #ifdefs.

* intern.h (rb_div): added for Ruby's behavior.

* intern.h (rb_mod): added for Ruby's behavior.

* insns.def (opt_div): use rb_div.

* insns.def (opt_mod): use rb_mod.

* numeric.c (fixdivmod): removed.

* numeric.c (fix_divide): use rb_div.

* numeric.c (fix_mod): use rb_mod.

* numeric.c (fix_divmod): use rb_divmod.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-08 09:15:18 +00:00
nobu 60dad06d53 numeric.c: wrong type step should raise TypeError
* numeric.c (num_step_scan_args): comparison String with Numeric
  should raise TypeError. it is an invalid type, but not a
  mismatch the number of arguments.  [ruby-core:62430] [Bug #9810]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-26 05:41:37 +00:00
nobu 53ec85b5b4 numeric.c: micro optimizations
* numeric.c (flo_to_s, rb_fix2str): use rb_usascii_str_new instead
  of rb_usascii_str_new_cstr, when the length can be calculated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-24 02:20:45 +00:00
nobu a8f4398602 numeric.c: adjust types
* numeric.c (coerce_rescue, coerce_rescue_quiet): rescue functions
  should have errinfo too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-17 02:54:50 +00:00
nobu e18654fff2 numeric.c: adjust types
* numeric.c (coerce_body, coerce_rescue, coerce_rescue_quiet):
  adjust parameter types for rb_rescue.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-17 02:38:09 +00:00
nobu 527fa61087 numeric.c: fix segfault
* numeric.c (compare_with_zero): fix variable name, rb_cmperr
  requires VALUEs but not an ID.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-16 09:25:08 +00:00
hsbt 52cd994814 * enum.c: fix a typo in documentation.
[ci skip][fix GH-1140] Patch by @jutaz
* io.c: ditto.
* iseq.c: ditto.
* numeric.c: ditto.
* process.c: ditto.
* string.c: ditto.
* vm_trace.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14 02:52:14 +00:00
kosaki 3a48e12607 * numeric.c: Good-by Borland-C.
* include/ruby/backward/rubyio.h: ditto.
* include/ruby/backward/st.h: ditto.
* include/ruby/backward/util.h: ditto.
* include/ruby/backward/rubysig.h: ditto.
* include/ruby/backward/classext.h: ditto.
* dln.c: ditto.
* gc.c: ditto.
* win32/resource.rb: ditto.
* win32/dir.h: ditto.
* ext/tk/tcltklib.c: ditto.
* NEWS: announce that Borland-C is no longer supported.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18 02:10:34 +00:00
nobu e0c038cdfb numeric.c: use predefined IDs
* numeric.c: use predefined IDs and prepared IDs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12 00:08:58 +00:00
nobu 5f0d9e8644 numeric.c: common expressions
* numeric.c (flo_pow): extract common expressions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12 00:08:44 +00:00
ko1 0a40bcb20b * vm_eval.c, internal.h (rb_yield_1): added for performance which
doesn't check Qundef.
* numeric.c (int_dotimes): use rb_yield_1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10 21:22:54 +00:00
svn 57149f76eb * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 06:42:18 +00:00
zzak 2c5a139a84 * numeric.c: [DOC] Overview for Numeric class by Joe Corcoran
This patch was created at ROSSConf Berlin 2015 [Bug #11555]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 06:42:14 +00:00
nobu 4191a6b90d preserve encodings in error messages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28 02:40:46 +00:00
akr 11dde7770d * numeric.c (Init_Numeric): Fix document for Float::MIN and
Float::EPSILON.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11 14:01:22 +00:00
nobu 545086d2c7 fix doc for Numeric#coerce [ci skip]
* numeric.c (num_coerce): [DOC] fix doc for Numeric#coerce,
  missing '+'.  [Fix GH-974]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22 00:45:33 +00:00
eregon 2e1835b69d * numeric.c (Numeric#negative?): [DOC] Fix call-seq.
Patch by @yui-knk. [Fixes GH-908]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-24 15:33:08 +00:00
nobu 59b089bd09 numeric.c: return true
* numeric.c (num_positive_p): return true instead of Fixnum 0.
  [ruby-core:69173] [Feature #11151]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-19 04:13:22 +00:00
nobu b4e5bff89d numeric.c: Bignum 0 is not positive
* numeric.c (num_positive_p): should false on Bignum 0.
  http://twitter.com/rafaelfranca/status/600509783427391488
  [ruby-core:69173] [Feature #11151]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-19 04:10:12 +00:00
nobu 932e916b9e numeric.c: Numeric#positive? and Numeric#negative?
* numeric.c (num_positive_p, num_negative_p): add methods
  Numeric#positive? and Numeric#negative?.
  [ruby-core:69173] [Feature #11151]
* numeric.c (flo_positive_p, flo_negative_p): specialiazed
  functions for Float.
* complex.c (Init_Complex): Complex do not have positive? and
  negative? methods

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-17 06:01:47 +00:00
nobu 8953b97d72 numeric.c: compare_with_zero
* numeric.c (compare_with_zero): raise TypeError when not
  comparable with 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-17 05:59:36 +00:00
nobu 3bcf9fb53e hash.c: same hash values with Float#hash
* hash.c (rb_any_hash): use same hash values with Float#hash so
  that -0.0 and +0.0 will be identical.
  [ruby-core:68541] [Bug #10979]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18 03:01:58 +00:00
nobu ed00379c79 numeric.c: calculate complex numbers
* numeric.c (fix_plus, fix_mul): calculate complex numbers for
  commutative operations.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-24 13:59:06 +00:00
nobu 16294913f7 use rb_funcallv
* use rb_funcallv() for no arguments call instead of variadic
  rb_funcall().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16 04:08:52 +00:00
nobu 6a852f7ab8 numeric.c: fix message
* numeric.c (coerce_failed): fix the error message on non-flonum
  platforms.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-13 12:07:14 +00:00
normal 34289fff0f numeric.c: correct error message when coerce fails
* numeric.c (bit_coerce): use original value for error message
  [ruby-core:67405] [Bug #10711]
* test/ruby/test_numeric.rb (test_coerce): check error message

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12 09:56:14 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
ko1 68f55c4b35 * dir.c (glob_helper): use #ifdef instead of #if.
gcc's -Wundef option shows warning for undefined macro.
* numeric.c (flo_is_finite_p): ditto.
* vm_dump.c (rb_vmdebug_thread_dump_state): ditto.
* vm_core.h: define VM_DEBUG_VERIFY_METHOD_CACHE to 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04 08:50:31 +00:00
nobu 52b59fc9d9 numeric.c: 0 % Float::NAN returns Float::NAN
* numeric.c (flodivmod): all results are NaN if divisor is NaN.
  [fix GH-692]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-01 07:35:48 +00:00
nagachika 71336a03fa * numeric.c (num_step_scan_args): table argument of rb_get_kwargs() is
array of IDs, not Symbols. [ruby-dev:48353] [Bug #9811]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-01 14:36:03 +00:00
eregon a21ac07f69 * numeric.c (do_coerce): Add a warning when an exception is raised
or an invalid value is returned in #coerce called by
  numeric comparison operators and the exception
  thrown by the caller has no information on the failure.
  In the next release such exception should not be rescued or
  should be the cause of the caller exception. nil is accepted
  as the "no possible coercion" return value. See #7688.
* test/ruby/test_numeric.rb: Add corresponding test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-07 13:16:01 +00:00
eregon ea7ce3096e * numeric.c (bit_coerce): remove constant parameter `err'
(always TRUE) of bit_coerce().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-07 09:16:21 +00:00
nobu f2980e3e20 encoding.h: constify rb_encoding
* include/ruby/encoding.h: constify `rb_encoding` itself, not only
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-02 20:23:47 +00:00
nobu 046831094b constify rb_encoding and OnigEncoding
* include/ruby/encoding.h: constify `rb_encoding` arguments.
* include/ruby/oniguruma.h: constify `OnigEncoding` arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-01 22:06:11 +00:00
nobu c0dba956d1 id.def: predefine to_i
* defs/id.def: predefine `to_i` as well as `to_int`.

* numeric.c (id_to_i): use predefined `idTo_i`.

* object.c (conv_method_names): add `to_i` ID.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-20 08:28:33 +00:00
akr 63fee73500 * configure.in: Check nextafter() availability.
* include/ruby/missing.h (nextafter): New optional declaration.

* missing/nextafter.c: New file.

* numeric.c: Float#next_float and Float#prev_float implemented.

   [ruby-core:62562] [Feature #9834]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 00:37:10 +00:00
nobu a352b0a207 numeric.c: check keyword arguments
* numeric.c (num_step_scan_args): check keyword arguments and fail
  if they conflict with positional arguments.
  [ruby-dev:48177] [Bug #9811]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 08:24:09 +00:00
nobu f8661f7ffb numeric.c: merge miss
* numeric.c (num_step_scan_args): fix merge miss.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 08:10:00 +00:00
nobu ba90ac2529 numeric.c: num_step_scan_args
* numeric.c (num_step_scan_args): turn a macro into a function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 08:05:00 +00:00
nobu 5c5180256a numeric.c: indent
* numeric.c (ruby_num_interval_step_size): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 07:34:33 +00:00
akr a6024cdc1b * numeric.c (rb_num2long): Returns a long.
(rb_num2ulong): Returns a unsigned long.

* bignum.c (rb_big2long): Returns a long.
  (rb_big2ulong): Returns a unsigned long.

* include/ruby/intern.h: Follow above changes.

* include/ruby/ruby.h: Follow above changes.
  (rb_num2long_inline): No need to cast.
  (rb_num2ulong_inline): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 15:46:32 +00:00
ko1 57e557908a * enumerator.c (enumerator_block_call): use PARRAY_CONST_PTR()
instead of RARRAY_PTR().
* io.c (rb_io_s_popen): ditto.
* numeric.c (num_step_size): ditto.
* vm_eval.c (rb_apply): ditto.
* vm_eval.c (rb_eval_cmd): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17 04:20:16 +00:00
nobu fc23374f06 [DOC] add links to `Object#hash`
add links to `Object#hash` to each #`hash` methods rdocs.
[Fixes GH-567]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14 01:27:43 +00:00
marcandre 9047641ce3 * numeric.c: Mention that Float::DIG is the minimum number
of siginificant digits. See #9191

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 01:55:02 +00:00
nobu e8b9611b32 numeric.c: predefined constants
* numeric.c (id_eq, id_cmp): use predefined constants in id.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 15:47:52 +00:00
nobu 99431e7355 numeric.c: float overflow
* numeric.c (ruby_num_interval_step_size): get rid of float
  conversion overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 05:11:44 +00:00
nobu a4a551f856 numeric.c: integer overflow
* numeric.c (ruby_num_interval_step_size): get rid of integer
  overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 04:59:49 +00:00
marcandre d596ba8dc0 * numeric.c: Fix rdoc for step
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:19:21 +00:00
marcandre 1636c60fe1 * numeric.c: Fix Numeric#step with 0 unit [#9575]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:04:59 +00:00
marcandre 11a57c63f3 * numeric.c: Simplify by getting rid of macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:04:43 +00:00
marcandre 814fb8e6c7 * numeric.c: Create var for rb_intern("<=>")
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:04:28 +00:00
marcandre e184e31c09 * numeric.c: Simplify [ruby-core:61106] [Bug #9570]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:03:30 +00:00
nobu c1fc20124c numeric.c: check signs before division
* numeric.c (ruby_num_interval_step_size): check signs and get rid
  of implementation dependent behavior of negative division.
  [ruby-core:61106] [Bug #9570]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 03:10:12 +00:00
akr 3c99764bcd * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.
(BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS.
  (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX.
  (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT.
  (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN.
  (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN.
  (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P.
  (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P.
  (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG.
  (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK.
  (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT.
  (BIGNUM_LEN): Renamed from RBIGNUM_LEN.
  (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS.
  (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT.

* bignum.c: Follow the above change.

* gc.c: Ditto.

* marshal.c: Ditto.

* math.c: Ditto.

* numeric.c: Ditto.

* random.c: Ditto.

* rational.c: Ditto.

* sprintf.c: Ditto.

* ext/-test-/bignum/bigzero.c: Ditto.

* ext/-test-/bignum/intpack.c: Ditto.

* ext/bigdecimal/bigdecimal.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-15 21:17:34 +00:00
akr 2fee22f30d [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-11 16:40:41 +00:00
zzak 65fd879a0a * numeric.c: [DOC] Fix typo in example for #step [ci skip]
Patch by @ksss [Fixes GH-522] https://github.com/ruby/ruby/pull/522


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-31 21:05:52 +00:00
nobu eb6575e137 numeric.c: preserve encoding
* numeric.c (num_init_copy): preserve encoding of error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 08:16:42 +00:00
nobu c1b4b10a12 numeric.c: preserve encoding
* numeric.c (num_sadded): preserve encoding of error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 08:16:40 +00:00
nobu 3ea61a2cf5 numeric.c: FLOAT_OUT_OF_RANGE
* numeric.c (FLOAT_OUT_OF_RANGE): extract a macro and a helper to
  raise RangeError of float.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 08:16:38 +00:00
nobu 2c65cdd319 numeric.c: preserve encoding
* numeric.c (coerce_failed): preserve encoding of error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 08:16:37 +00:00
a_matsuda 38e89273ed * numeric.c: Fix typo in an error message
s/unsgined/unsigned/

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-07 14:29:41 +00:00
nobu 006e66b668 numeric.c: isfinite
* numeric.c (flo_is_finite_p): prefer C99 standard isfinite() than
  deprecated finite().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-05 12:33:42 +00:00
nobu 09b02349c2 numeric.c: no declaration of finite
* numeric.c (finite): disable declaration on Windows, which can be
  defined in ruby/win32.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-10 06:33:34 +00:00
mame 487a25d29b * numeric.c (fix_aref): avoid a possible undefined behavior.
1L << 63 on 64-bit platform is undefined, at least, according to
  ISO/IEC 9899 (C99) 6.5.7.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-09 15:08:41 +00:00
nobu d700d34043 internal.h: move inline functions
* internal.h (rb_float_value, rb_float_new): move inline functions
  from ruby/ruby.h.
* numeric.c (rb_float_value, rb_float_new): define external functions
  for extension libraries.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 07:58:49 +00:00
nobu ed6c17f75c numeric.c: use RB_TYPE_P
* numeric.c: use RB_TYPE_P() for special classes instead of switch
  with TYPE().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-11 08:23:06 +00:00
nobu 9b6ee42d86 numeric.c: use positive_int_p
* numeric.c (NUM_STEP_SCAN_ARGS): use positive_int_p() to fix rubyspec
  failures.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:33 +00:00
nobu ba6c734847 numeric.c: no extra checks
* numeric.c (NUM_STEP_SCAN_ARGS): remove extra class checks, which
  cause the incompatibilities.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:28 +00:00
nobu 326e38164b numeric.c: split NUM_STEP_GET_INF
* numeric.c (NUM_STEP_GET_INF): split from NUM_STEP_SCAN_ARGS(), since
  inf is not used in num_step_size().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 13:57:02 +00:00
knu c68596aef1 Retain behavior of Numeric#step when nil is given as second argument.
* numeric.c (NUM_STEP_SCAN_ARGS): On sencond thought, keep
  Numeral#step backward compatible in that it raises TypeError
  when nil is given as second argument.

* test/ruby/test_float.rb (TestFloat#test_num2dbl): Revert.

* test/ruby/test_numeric.rb (TestNumeric#test_step): Fix test
  cases for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 22:54:58 +00:00
knu 4993cf9e24 Numeral#step should raise TypeError if a non-numeric parameter is given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 22:39:22 +00:00
knu fd4b5b8dc8 Enhance Numeric#step.
* numeric.c (num_step): Default the limit argument to infinity and
  allow it to be omitted.  Keyword arguments (by: and to:) are
  introduced for ease of use. [Feature #8838] [ruby-dev:47662]
  [ruby-dev:42194]

* numeric.c (num_step): Optimize for infinite loop.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 14:56:06 +00:00
akr 77f245e62e * numeric.c (rb_fix_bit_length): Moved from bignum.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 01:31:16 +00:00
ktsj 22bfbc9419 * numeric.c: [DOC] fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10 05:02:56 +00:00
akr ba3ec382c7 [DOC] refine a call seq.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 03:33:22 +00:00
nobu 7c9a3d19fc parse.y: calculate powers of ten
* parse.y (parser_yylex): calculate denominator directly as powers of
  ten, not parsing string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:48:55 +00:00
zzak 4314d8c2e3 * numeric.c: [DOC] improve rdoc formatting for parameters and links
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 18:27:23 +00:00
zzak ceda881601 * numeric.c (rb_cNumeric): [DOC] Added comment for Numeric to fix doc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 02:33:58 +00:00
nobu 9487b2cdfc numeric.c: for strict ANSI
* numeric.c (finite): add declaration for strict ANSI.
  [ruby-core:55312] [Bug #8495]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 14:12:52 +00:00
charliesome 7ffd3e9444 * numeric.c (fix_mul): remove FIT_SQRT_LONG test as it was causing
fix_mul to return an incorrect result for -2147483648*-2147483648
  on 64 bit platforms

* test/ruby/test_integer_comb.rb (class TestIntegerComb): add test case

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-28 16:09:08 +00:00
nobu 5e2f227d21 intern.h: define rb_enumerator_size_func
* include/ruby/intern.h (rb_enumerator_size_func): define strict
  function declaration for rb_enumeratorize_with_size().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 13:43:22 +00:00
akr 633e4949bd * numeric.c (rb_num_to_uint): Use rb_absint_size instead of
RBIGNUM_LEN.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 14:57:28 +00:00
mrkn 5385ae9af4 * rational.c (numeric_quo): move num_quo in numeric.c to numeric_quo
in rational.c to refer canonicalization state for mathn support.
  [ruby-core:41575] [Bug #5736]

* numeric.c (num_quo): ditto.

* test/test_mathn.rb: add a test for the change at r41109.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:50:32 +00:00
eregon 896619c77b * numeric.c: remove unused ID id_to_r introduced in r41109.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06 21:49:45 +00:00
mrkn 7708560bb1 * numeric.c (num_quo): Use to_r method to convert the receiver to
rational.  [ruby-core:41575] [Bug #5736]

* test/ruby/test_numeric.rb: add a test for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06 13:31:22 +00:00
mrkn febc42d05c * numeric.c (num_quo): should return a Float for a Float argument.
[ruby-dev:44710] [Bug #5515]

* test/ruby/test_fixnum.rb: Add an assertion for the above change.

* test/ruby/test_bignum.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06 01:04:11 +00:00
ko1 4f401816ff * gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
  check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
  you want to access raw pointers. If you modify the contents which
  pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
  and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
  barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
  generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
  FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
  move flag bits.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
zzak 704abdc3d2 * numeric.c: Fix wiki link on Float imprecision in overview, patched
by Makoto Kishimoto [Bug #8304] [ruby-dev:47280]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 05:08:47 +00:00
zzak 9ef4e13459 * array.c: Document synonymous methods, by windwiny [GH-277]
* bignum.c: ditto
* complex.c: ditto
* dir.c: ditto
* encoding.c: ditto
* enumerator.c: ditto
* numeric.c: ditto
* proc.c: ditto
* re.c: ditto
* string.c: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12 02:59:07 +00:00
akr 712c7168bf * internal.h (MUL_OVERFLOW_SIGNED_INTEGER_P): New macro.
(MUL_OVERFLOW_FIXNUM_P): Ditto.
  (MUL_OVERFLOW_LONG_P): Ditto.

* array.c (rb_ary_product): Don't overflow on signed integer
  multiplication.

* numeric.c (fix_mul): Ditto.
  (int_pow): Ditto.

* rational.c (f_imul): Ditto.

* insns.def (opt_mult): Ditto.

* thread.c (sleep_timeval): Don't overflow on signed integer addition.

* bignum.c (rb_int2big): Don't overflow on signed integer negation.
  (rb_big2ulong): Ditto.
  (rb_big2long): Ditto.
  (rb_big2ull): Ditto.
  (rb_big2ll): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09 11:39:53 +00:00
akr d6daffbbf0 * numeric.c (rb_num2ulong_internal): Don't cast a negative double value
into unsigned long, which is undefined behavior.
  (rb_num2ull): Don't cast a value bigger than LLONG_MAX into
  long long, which is undefined behavior.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-01 12:14:30 +00:00
akr 4e52c3c60c * numeric.c (rb_num2long): Don't use SIGNED_VALUE uselessly.
(check_int): Ditto.
  (check_short): Ditto.
  (rb_num2fix): Ditto.
  (rb_num2ulong_internal): Add a cast.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-01 11:08:44 +00:00
akr 92f59c6d79 * numeric.c (check_uint): Take the 1st argument as unsigned long,
instead of VALUE.  Refine the validity test conditions.
  (check_ushort): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-01 03:06:09 +00:00
akr 59182ccf69 * numeric.c (rb_num2ulong_internal): New function similart to
rb_num2ulong but integer wrap around flag is also returned.
  (rb_num2ulong): Use rb_num2ulong_internal.
  (rb_num2uint): Use rb_num2ulong_internal and the wrap around flag is
  used instead of negative_int_p(val).
  (rb_num2ushort): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-31 04:51:29 +00:00
akr 1950c1ce6c * numeric.c (rb_num2ull): Cast double to unsigned LONG_LONG via
LONG_LONG instead of double to unsigned LONG_LONG directly.
  This is a challenge to fix a test_num2ull(TestNum2int)
  failure (NUM2ULL(-1.0) should be "18446744073709551615" but was "0")
  on Mac OS X with 32bit clang.
  http://a.mrkn.jp/~mrkn/chkbuild/mountain_lion/ruby-trunk-m32-o0/log/20130328T191100Z.diff.html.gz


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-28 21:49:55 +00:00
akr 83f1be1bc3 * numeric.c (LONG_MIN_MINUS_ONE_IS_LESS_THAN): New macro.
(LLONG_MIN_MINUS_ONE_IS_LESS_THAN): Ditto.
  (rb_num2long): Use LONG_MIN_MINUS_ONE_IS_LESS_THAN.
  (rb_num2ulong): Ditto.
  (rb_num2ll): Use LLONG_MIN_MINUS_ONE_IS_LESS_THAN.
  (rb_num2ull): Ditto.

* test/-ext-/num2int/test_num2int.rb (asert_num2i_success): Test the
  value converted into a Float if Float can represent the value
  exactly.
  (asert_num2i_error): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-27 13:12:27 +00:00
nobu 2d1c94a18d prefix global symbols
* iseq.c (rb_insn_operand_intern): prefix global symbols.

* numeric.c (ruby_num_interval_step_size): ditto.

* vm_backtrace.c (rb_vm_backtrace_str_ary),
  (rb_vm_backtrace_location_ary, rb_vm_thread_backtrace),
  (rb_vm_thread_backtrace_locations): ditto.

* vm_trace.c (rb_vm_trace_mark_event_hooks): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-06 06:30:03 +00:00
nobu 4a429c11e1 enumerator.c: allow Bignum for with_index
* enumerator.c (enumerator_with_index_i): allow Bignum as offset, to
  get rid of conversion exception and integer overflow.
  [ruby-dev:47131] [Bug #8010]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 01:20:20 +00:00
nobu ce357ef152 numeric.c: optimize for Bignum
* numeric.c (rb_int_succ, rb_int_pred): shortcut optimization for
  Bignum.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 01:18:55 +00:00
zzak c2204ca328 * array.c: Document #<=> return values and formatting
* bignum.c: ditto
* file.c: ditto
* object.c: ditto
* numeric.c: ditto
* rational.c: ditto
* string.c: ditto
* time.c: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 03:35:38 +00:00
nobu 3f2ce6373f random.c: fix error message
* random.c (rb_random_ulong_limited): fix error message for negative
  value.  [ruby-dev:47061] [Bug #7903]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22 03:46:47 +00:00
zzak 8d4a11c919 * numeric.c: Examples and formatting for Numeric and Float
Based on a patch by Zach Morek and Oren K of newhaven.rb
  [Github documenting-ruby/ruby#5]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22 02:01:28 +00:00
marcandre d22ce4a522 * numeric.c (fix_pow): Handle special cases when base is 0, -1 or +1
[Bug #5713] [Bug #5715]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 05:39:49 +00:00
marcandre 075ae2955c * numeric.c: Fix rdoc for Fixnum#**
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 05:39:16 +00:00
zzak a954def1fb * numeric.c: Document Float constants [ruby-core:51484] [Bug #7709]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-03 00:59:51 +00:00
mrkn 350c448da8 * numeric.c (do_coerce): fix for the exceptions which the coerce
method raises.  The optimization done by r38756 is preserved.
  [Bug #7645] [ruby-core:51213]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-12 08:47:18 +00:00
eregon 8307cb90a0 * numeric.c (do_coerce): fix comment and adjust indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10 08:12:58 +00:00
shugo 42eadff3a1 * numeric.c (do_coerce): remove an unused variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10 06:57:17 +00:00
mrkn 9aa75d08ce * numeric.c (do_coerce): speed optimization by using rb_check_funcall
instead of rb_rescue + rb_funcall.
  This fix is based on the patch by Benoit Daloze.
  [Bug #7645] [ruby-core:51213]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10 06:30:23 +00:00
nobu e878df745c use RB_TYPE_P
* enumerator.c (enumerator_initialize), eval.c (rb_using_refinement),
  (add_activated_refinement), numeric.c (num_interval_step_size),
  parse.y (arg, match_op_gen, cond0), range.c (range_bsearch),
  vm_insnhelper.c (vm_get_iclass): use RB_TYPE_P() to optimize.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:22:01 +00:00
mrkn a756488c6d * include/ruby/intern.h: add the prototype declaration of
rb_num_coerce_bit.

* numeric.c (rb_num_coerce_bit): the new coerce function for bitwise
  binary operation.

* bignum.c (rb_big_and): use coerce to convert the argument, which isn't
  a Fixnum nor a Bignum, to the corresponding Integer object so that
  bitwise operations can support Integer-mimic objects.
  [Bug #1792] [ruby-core:39491]

* bignum.c (rb_big_or): ditto.

* bignum.c (rb_big_xor): ditto.

* numeric.c (bit_coerce): ditto.

* numeric.c (fix_and): ditto.

* numeric.c (fix_or): ditto.

* numeric.c (fix_xor): ditto.

* test/ruby/test_integer.rb: add tests for the above changes.

* test/ruby/test_bignum.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22 15:06:22 +00:00
ko1 f6f388a5bd * array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,
range.c: use prepared IDs.
  A patch from charliesome (Charlie Somerville).
  [Bug #7495]
* common.mk: add dependency to id.h.
* common.mk: replace ID_H_INCLUDES with id.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 09:57:47 +00:00
nobu 66fd9d44d8 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 15:25:28 +00:00
mrkn 6ea34efab0 * numeric.c: Add description of that the results of the comparing
operations of two NaNs are undefined.
  [#1720] [ruby-dev:38725] [ruby-core:36966]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-08 00:34:55 +00:00
naruse 172d8f9b6e * numeric.c (ruby_float_step): fix r37514: it yielded with NaN
if the unit is infinity.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-07 07:03:50 +00:00
nobu 7f00f853d4 adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 22:50:30 +00:00
marcandre 3a4eb4dd39 * numeric.c (int_dotimes): Support for Integer#times.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:15:30 +00:00
marcandre c2dc0dc1ce * numeric.c (int_upto, int_downto): Support for Integer#{down|up}to.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:15:15 +00:00
marcandre 34be3a5d90 * numeric.c (num_step): Support for Numeric#step.size
[Feature #6636]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 17:14:31 +00:00
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