big_lshift and big_rshift are merged.
(big_shift2): New function.
(big_lshift): Use big_shift3.
(big_rshift): Ditto.
(check_shiftdown): Removed.
(rb_big_lshift): Use big_shift2 and big_shift3.
(rb_big_rshift): Ditto.
(big_lshift): Removed.
(big_rshift): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigrsh_bang): Ditto.
(bigmul1_toom3): Use bary_small_lshift and bary_small_rshift.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(mulfunc_t): New type.
(bary_mul_toom3_start): Renamed from bary_mul.
(bary_mul_karatsuba_start): Renamed from bary_mul.
(bary_mul_balance_with_mulfunc): Renamed from bary_mul_balance and
new argument, mulfunc, is added.
(rb_big_mul_balance): Invoke bary_mul_balance_with_mulfunc with
bary_mul_toom3_start.
(bary_mul_karatsuba): Invoke bary_mul_karatsuba_start instead of
bary_mul.
(bary_mul_precheck): Extracted from bary_mul.
(bary_mul_karatsuba_branch): Extracted from bary_mul.
(bary_mul_karatsuba_start): New function to call bary_mul_precheck
and bary_mul_karatsuba_branch.
(bary_mul_toom3_branch): Extracted from bary_mul.
(bary_mul_toom3_start): New function to call bary_mul_precheck and
bary_mul_toom3_branch.
(bary_mul): Just call bary_mul_toom3_start.
Arguments for work memory are removed.
(rb_cstr_to_inum): Follow the bary_mul change.
(bigmul0): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_add_one): Replaced by the implementation of bary_plus_one.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (maxpow_in_bdigit_dbl, maxpow_in_bdigit): select by
preprocessor conditions to reduce dead code and suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_sub): Returns a borrow flag. Use bary_subb.
(bary_subb): New function for actually calculating subtraction with
borrow.
(bary_sub_one): New function.
(bigadd_core): Use bary_add.
(bary_add): Returns a carry flag. Use bary_addc.
(bary_addc): New function for actually calculating addition with
carry.
(bary_add_one): New function.
(bary_muladd_1xN): Extracted from bary_mul_normal.
(bigmul1_normal): Removed.
(bary_mul_karatsuba): New function.
(bary_mul1): Invoke rb_thread_check_ints after bary_mul_normal.
(bary_mul): Remove most and least significant zeros before actual
multiplication. Use bary_sq_fast, bary_mul_balance,
bary_mul_karatsuba and bigmul1_toom3 as bigmul0.
(bigmul1_balance): Removed.
(bigmul1_karatsuba): Removed.
(bigsqr_fast): Removed.
(bary_sparse_p): Extracted from big_sparse_p.
(big_sparse_p): Removed.
(bigmul0): Use bary_mul.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
ensure not to access zds[2*xn].
(bigsqr_fast): Allocate the result bignum with 2*xn words.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(maxpow_in_bdigit): Ditto.
(U16): New macro.
(U32): Ditto.
(U64): Ditto.
(U128): Ditto.
(maxpow16_exp): New table.
(maxpow16_num): New table.
(maxpow32_exp): New table.
(maxpow32_num): New table.
(maxpow64_exp): New table.
(maxpow64_num): New table.
(maxpow128_exp): New table.
(maxpow128_num): New table.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(BDIGIT_DBL_MAX): New macro.
(maxpow_in_bdigit_dbl): New function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_cstr_to_inum): Use a better algorithm to compose the result
if input length is very long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(nlz32): Ditto.
(nlz64): Ditto.
(nlz128): Ditto.
(nlz): Redefined using an above function.
(bitsize): New macro.
(rb_cstr_to_inum): Use bitsize instead of nlz.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_plus_one): Extracted from bary_2comp.
(bary_2comp): Use bary_neg and bary_plus_one.
(big_extend_carry): Extracted from get2comp.
(get2comp): Use big_extend_carry.
(rb_integer_unpack): Use big_extend_carry.
(rb_big_neg): Use bary_neg.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigxor_int): Take xn and hibitsx arguments. Use twocomp2abs_bang.
(rb_big_xor): Use abs2twocomp and twocomp2abs_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigor_int): Take xn and hibitsx arguments. Use twocomp2abs_bang.
(rb_big_or): Use abs2twocomp and twocomp2abs_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(abs2twocomp): Take n_ret argument to return actual length.
(rb_big_and): Follow above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(abs2twocomp_bang): New function.
(abs2twocomp): New function.
(twocomp2abs_bang): New function.
(rb_big_and): Use abs2twocomp and twocomp2abs_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigor_int): The allocated bignum should have enough size
to store long.
This fixes (bignum fits in a BDIGIT) | (fixnum bigger than BDIGIT)
on platforms which SIZEOF_BDIGITS < SIZEOF_LONG,
such as LP64 with 32bit BDIGIT (no int128).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_big_aref): Call big2ulong with TRUE for "check" argument.
It should be non-effective.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
"-u" to suppress warning (C4146) by Visual Studio.
Reported by ko1 via IRC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(BDIGIT_MSB): Defined using BIGRAD_HALF.
(bary_2comp): Apply BIGLO after possible over flow of BDIGIT.
(get2comp): Ditto.
(bary_unpack_internal): Use BDIGIT_MSB.
Apply BIGLO after possible over flow of BDIGIT.
(rb_integer_unpack): Use BDIGIT_MSB.
(calc_hbase): Use BDIGMAX.
(big2dbl): Use BDIGMAX.
Apply BIGLO after possible over flow of BDIGIT.
(rb_big_neg): Apply BIGLO after possible over flow of BDIGIT.
(biglsh_bang): Ditto.
(bigrsh_bang): Ditto.
(bary_divmod): Use BDIGIT_MSB.
(bigdivrem): Ditto.
(bigxor_int): Apply BIGLO after possible over flow of BDIGIT.
* marshal.c (shortlen): Use SIZEOF_BDIGITS instead of sizeof(BDIGIT).
* ext/openssl/ossl_bn.c (ossl_bn_initialize): Use SIZEOF_BDIGITS
instead of sizeof(BDIGIT).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (big2ulong): suppress shorten-64-to-32 warning. BDIGIT can
be bigger than long now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
of x is bigger than BDIGIT_DBL.
(big2ulong): Use unsigned long to store the result.
(big2ull): Use unsigned LONG_LONG to store the result.
(bigand_int): Use long for num to avoid data loss.
(bigor_int): Ditto.
(bigxor_int): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_pack): Use bytes_2comp.
(rb_quad_pack): Use rb_integer_pack.
(rb_quad_unpack): Use rb_integer_unpack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_unpack): Support INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION.
(rb_integer_unpack): Support INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION flag.
Fix byte order and word order handling in code specialized for
wordsize % SIZEOF_BDIGITS == 0.
* internal.h (INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION): Defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(RSHIFTX): Ditto.
(CLEAR_LOWBITS): Use LSHIFTX and RSHIFTX.
(FILL_LOWBITS): Use LSHIFTX.
Reported by ko1 via IRC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(HOST_BIGENDIAN_P): New macro.
(ALIGNOF): New macro.
(CLEAR_LOWBITS): New macro.
(FILL_LOWBITS): New macro.
(swap_bdigit): New macro.
(bary_2comp): Returns an int.
* internal.h (swap16): Moved from pack.c
(swap32): Ditto.
(swap64): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_unpack): Set the overflowed bit if an extra BDIGIT exists.
(rb_integer_unpack): Set the overflowed bit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bigfixize): Refine an ifdef condition.
(rb_absint_size): Use bdigit_roomof.
(rb_absint_singlebit_p): Ditto.
(rb_integer_pack): Ditto.
(integer_pack_fill_dd): Use BITSPERDIG.
(integer_unpack_push_bits): Use BITSPERDIG, BIGLO and BIGDN.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(DIGSPERLL): Don't define if BDIGIT is bigger than LONG_LONG
(rb_absint_size): Consider environments BDIGIT is bigger than long.
Use BIGLO and BIGDN.
(rb_absint_singlebit_p): Ditto.
(rb_integer_pack): Ditto.
(bigsub_int): Consider environments BDIGIT is bigger than long.
Use SIZEOF_BDIGITS instead of sizeof(BDIGIT).
(bigadd_int): Ditto.
(bigand_int): Ditto.
(bigor_int): Ditto.
(bigxor_int): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/defines.h (BDIGIT_DBL): Use uint128_t if it is available.
(BDIGIT): Use uint64_t if uint128_t is available.
(SIZEOF_BDIGITS): Defined for above case.
(BDIGIT_DBL_SIGNED): Ditto.
(PRI_BDIGIT_PREFIX): Ditto.
* include/ruby/ruby.h (PRI_64_PREFIX): Defined.
* bignum.c (rb_big_pow): Don't use BITSPERDIG for the condition which
rb_big_pow returns Float or Bignum.
[ruby-dev:47413] [Feature #8509]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(integer_unpack_num_bdigits): Extracted from
rb_integer_unpack_internal.
(bary_unpack_internal): Renamed from bary_unpack and support
INTEGER_PACK_2COMP.
(bary_unpack): New function to validate arguments and invoke
bary_unpack_internal.
(rb_integer_unpack_internal): Removed.
(rb_integer_unpack): Invoke bary_unpack_internal.
(rb_integer_unpack_2comp): Removed.
* internal.h (rb_integer_unpack_2comp): Removed.
* pack.c: Follow the above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(bary_zero_p): Extracted from bigzero_p.
(absint_numwords_generic): Use bary_zero_p and bary_add.
(bary_mul): Fix an argument for bary_mul_single.
(bary_divmod): Use size_t for arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(absint_numwords_generic): Use bary_mul.
(bary_mul_single): Extracted from bigmul1_single.
(bary_mul_normal): Extracted from bigmul1_normal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
changed the intention of the expression) because VC++ reports a
warning for it. reported by ko1 via IRC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_integer_unpack_internal): Extracted from rb_integer_unpack and
nlp_bits_ret argument added.
(integer_unpack_num_bdigits_small): nlp_bits_ret argument added to
return number of leading padding bits.
(integer_unpack_num_bdigits_generic): Ditto.
* internal.h (rb_integer_unpack_2comp): Declared.
* pack.c (pack_unpack): Use rb_integer_unpack_2comp and
rb_integer_unpack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
flag if numwords is 1 or less.
(absint_numwords_generic): Don't specify a word order for
rb_integer_pack.
* hash.c (rb_hash): Ditto.
* time.c (v2w_bignum): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_integer_unpack.
(integer_unpack_num_bdigits_generic): Ditto.
(integer_unpack_num_bdigits_bytes): New function.
(rb_integer_unpack): Use above functions.
Return a Bignum for INTEGER_PACK_FORCE_BIGNUM evenwhen the result
is zero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(absint_numwords_generic): Use absint_numwords_small if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(absint_numwords_generic): Extracted from rb_absint_numwords.
(rb_absint_numwords): Use absint_numwords_bytes if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_big2str0): Use big2str_base_powerof2 if base is 2, 4, 8, 16 or 32.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* random.c: Use uint32_t for elements of seed.
(make_seed_value): Use rb_integer_unpack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_integer_unpack): Support INTEGER_PACK_FORCE_BIGNUM.
* random.c (int_pair_to_real_inclusive): Use
INTEGER_PACK_FORCE_BIGNUM to use rb_big_mul instead of rb_funcall.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
validate_integer_format.
(integer_pack_loop_setup): Renamed from integer_format_loop_setup.
(integer_pack_fill_dd): Renamed from int_export_fill_dd.
(integer_pack_take_lowbits): Renamed from int_export_take_lowbits.
(integer_unpack_push_bits): Renamed from int_import_push_bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in: revert r41106. size_t may not be unsigned
* bignum.c (rb_absint_size_in_word, rb_int_export, rb_int_import): use
NUM2SIZET() and SIZET2NUM() already defined in ruby/ruby.h.
* ext/-test-/bignum/export.c (rb_int_export_m): ditto.
* ext/-test-/bignum/import.c (rb_int_import_m): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Use nlz instead of bitlength_bdigit.
(bitlength_bdigit): Removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* internal.h (GCC_VERSION_SINCE): Macro moved from pack.c.
* pack.c: Include internal.h for GCC_VERSION_SINCE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/bigdecimal/bigdecimal.c (MUL_OVERFLOW_SIGNED_VALUE_P): New
macro.
(AddExponent): Don't overflow on signed integer multiplication.
(VpCtoV): Don't overflow on signed integer arithmetic.
(VpCtoV): Don't overflow on signed integer arithmetic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_big_eq): test as Fixnum if possible and get rid of zero
length Bignum. [ruby-core:53893] [Bug #8204]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c (recursive_check): object_id maybe a Bignum, not Fixnum on
LLP64. see also r38493 and r38548.
reported by Heesob Park at [ruby-core:51083] [Bug #7607], and patched
by shirosaki at [ruby-core:51095]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
bigdivrem so that the calculation is started from the point where
the last interruption was occurred.
* bignum.c (bigdivrem1): ditto.
* test/ruby/test_bignum.rb: add a test case for rb_bigdivrem in the
case that an interruption is occurred during bigdivrem1 is running.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
interrupted by signal. Otherwise, ruby script may see a garbage
value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[ruby-core:48552] [Bug #7242]
* test/ruby/test_bignum.rb (test_mul_large_numbers):
add a test for bigmul1_toom3 suggested in [Bug #7242].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (bigdivrem): move decrement to the loop body, to suppress
an empty-body warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
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
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
* encoding.c (load_encoding): explicit cast to suppress warning.
Though the cast truncates some bits, from heuristic analysis I
believe it is OK to do so here.
* bignum.c (rb_cstr_to_inum): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[ruby-core:31376] [Bug #3589] reported by Tomasz Wegrzanowski.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
well as String#hex and String#oct. [ruby-core:43566][Bug #6192]
* string.c (rb_must_asciicompat): check if ASCII compatible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
the range of VALUE is larger than it on LLP64 platform, such as Win64.
this change fixes the failures of test/-ext-/num2int.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
fail in certain case. this patch is contributed from Ray Chason
<chasonr at gmail.com> in personal communication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
its real range is ulong. So, if the size of VALUE is bigger than
ulong, upper bits are always zero even if the actual value is
negative.
fixed#3490
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_rand_internal and now this is public API.
* include/ruby/ruby.h (rb_genrand_ulong_limited): added.
* bignum.c (big_sparse_p): use rb_genrand_ulong_limited.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
which don't have 8bytes integer type. This still depends on little
endian.
(rb_quad_pack): use quad_buf_complement. don't raise for large
values.
(rb_quad_unpack): use quad_buf_complement.
(quad_buf_complement): new function extracted frm rb_quad_pack.
add one after bitwise negation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_quad_pack): use LONG_LONG version only if
SIZEOF_LONG_LONG == QUAD_SIZE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
denote that #to_i raises FloatDomainError for Inf and NaN.
* ext/bigdecimal/bigdecimal.c (BigDecimal_to_i): fast #to_i using
BigDecimal_split().
* bignum.c (conv_digit): use faster ISDIGIT() assuming ASCII.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
multiply two single digit bignums.
(bigmul0): use bigmul1_single.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
optimization.
* bignum.c (big2dbl): truncates zero digits to get rid of possible
underflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
bigmul1_balance, big_split): remove BDIGITS() inside of the loops.
same as r24444.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
can be converted to float properly.
* numeric.c (fix_fdiv): calls rb_big_fdiv when the given second
argument is a bignum.
* rational.c (nurat_fdiv): should calculate Float(x/y), not
Float(x)/Float(y).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e