* bignum.c (rb_cstr_parse_inum): stores the address of the first
invalid character when str is too big or contains an underscore.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RBIGNUM_SIGN): use a wrapper function to
return the sign bit, instead of comparing with 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rational.c (nurat_to_double): introduce to convert rational to double
without object allocation.
* rational.c (rb_rational_plus, nurat_{sub,mul,to_f}): rewrite by using
nurat_to_double.
* bignum.c (rb_big_fdiv_double): introduce to calculate fdiv and return
the result as a double value.
* bignum.c (big_fdiv{,_int,_float}): change the return types for
implementing rb_big_fdiv_double.
* bignum.c (rb_big_fdiv): rewrite by using rb_big_fdiv_double.
* numeric.c (rb_int_fdiv_double): introduce to calculate fdiv and return
the result as a double value.
* numeric.c (fix_fdiv_double): rewrite from fix_fdiv to return the
result as a double value.
* numeric.c (rb_int_fdiv): rewrite by using rb_int_fdiv_double.
* internal.h (rb_{big,int}_fdiv_double): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_big_and, rb_big_or, rb_big_xor): use dedicated
macro RB_INTEGER_TYPE_P instead of combination of FIXNUM_P and
RB_BIGNUM_TYPE_P.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
a hash value of Object might be Bignum, but it causes many troubles
expecially the Object is used as a key of a hash. so I've gave up
to do so.
* array.c (rb_ary_hash): use above macro.
* bignum.c (rb_big_hash): ditto.
* hash.c (rb_obj_hash, rb_hash_hash): ditto.
* numeric.c (rb_dbl_hash): ditto.
* proc.c (proc_hash): ditto.
* re.c (rb_reg_hash, match_hash): ditto.
* string.c (rb_str_hash_m): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c (Init_Numeric), bignum.c (Init_Bignum): deprecate
Fixnum and Bignum. this may be reverted after previews.
[Feature #12739]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
calculating `-(long)(num-1)-1` if `num` is not LONG_MIN. (Note that
`-LONG_MIN` may be larger than LONG_MAX) But C compilers can
optimize it into single NEG instruction.
Therefore those two conditions can be single if-body.
* bignum.c (rb_big2long): ditto.
* bignum.c (rb_big2ull): ditto.
* bignum.c (rb_big2ll): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RUBY_INTEGER_UNIFICATION): macro to tell if
Integer is integrated. [ruby-core:75718][Bug #12427]
* include/ruby/backward.h, internal.h (rb_cFixnum, rb_cBignum):
fallback to rb_cInteger.
* bignum.c, numeric.c, ext/json/generator/generator.{c,h}: use the
macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [Feature #12005] Unify Fixnum and Bignum into Integer
* include/ruby/ruby.h (rb_class_of): Return rb_cInteger for fixnums.
* insns.def (INTEGER_REDEFINED_OP_FLAG): Unified from
FIXNUM_REDEFINED_OP_FLAG and BIGNUM_REDEFINED_OP_FLAG.
* vm_core.h: Ditto.
* vm_insnhelper.c (opt_eq_func): Use INTEGER_REDEFINED_OP_FLAG instead
of FIXNUM_REDEFINED_OP_FLAG.
* vm.c (vm_redefinition_check_flag): Use rb_cInteger instead of
rb_cFixnum and rb_cBignum.
(C): Use Integer instead of Fixnum and Bignum.
* numeric.c (fix_succ): Removed.
(Init_Numeric): Define Fixnum as Integer.
* bignum.c (bignew): Use rb_cInteger instead of Rb_cBignum.
(rb_int_coerce): replaced from rb_big_coerce and return fixnums
as-is.
(Init_Bignum): Define Bignum as Integer.
Don't define ===.
* error.c (builtin_class_name): Return "Integer" for fixnums.
* sprintf.c (ruby__sfvextra): Use rb_cInteger instead of rb_cFixnum.
* ext/-test-/testutil: New directory to test.
Currently it provides utilities for fixnum and bignum.
* ext/json/generator/generator.c: Define mInteger_to_json.
* lib/mathn.rb (Fixnum#/): Redefinition removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
* 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
* bignum.c (rb_cstr_parse_inum): [EXPERIMENTAL] new function to
parse integer in C-string with length. the name and the
arguments may be changed in the future.
* bignum.c (rb_str_to_inum): preserve encoding of the argument in
error messages, and no longer needs to copy non-terminated
strings.
* bignum.c (rb_str2big_{poweroftwo,normal,karatsuba,gmp}): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_big_cmp): micro optimization of Fixnum comparison.
as SIGNED_VALUE and Fixnum have same sign-bits and same order.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_big_eq): If normalized bignum is still bignum,
it must be larger than fixnum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
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
other source files, and remove documentation comment for Bignum#hash.
* bignum.c (Bignum#hash): remove its definition because it is unified
with Object#hash.
* include/ruby/intern.h (rb_big_hash): add a prototype declaration.
* hash.c (any_hash): treat Bignum values directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
to be available in other source files.
* include/ruby/intern.h (rb_big_even_p, rb_big_odd_p): add prototype
declarations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_uint128t2big): added for opt_mult.
* bignum.c (rb_uint128t2big): added for rb_uint128t2big..
* configure.in: define int128_t, uint128_t and related MACROs.
Initially introduced by r41379 but reverted by r50749.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_assert_failure): assertion with stack dump.
* ruby_assert.h (RUBY_ASSERT): new header for the assertion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (roomof): extract from type_roomof, and move from
bignum.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
definition of a variable to fix compile error with older version
of fcc (Fujitsu C Compiler) 5.6 on Solaris 10 on Sparc.
[Bug #10350] [ruby-dev:48608]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* bignum.c, math.c: use type predicate macros instead of TYPE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_divmod_normal): New function.
(bary_divmod): Use bary_divmod_normal.
(bigdivrem): Use bary_divmod_normal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(str2big_gmp): New function.
(rb_cstr_to_inum): Use str2big_gmp for big bignums.
(rb_str2big_gmp): New function.
* internal.h (rb_str2big_gmp): Declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e