nobu
4dcad25b23
bignum.c: improve estimate
...
* bignum.c (estimate_initial_sqrt, rb_big_isqrt): improve initial
estimate by sqrt(). [ruby-core:79754] [Feature #13250 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-25 05:44:39 +00:00
nobu
dab7aa22f7
bignum.c (bary_zero_p): constify
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-25 04:13:42 +00:00
nobu
a67c94cf40
extract initial sqrt estimation [Feature #13219 ]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-24 23:31:07 +00:00
nobu
bdd6b995f9
Integer.sqrt [Feature #13219 ]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-24 08:36:16 +00:00
nobu
6feeda594e
bignum.c: NAIVE_MUL_DIGITS
...
* bignum.c (NAIVE_MUL_DIGITS): share threshold for bary_sq_fast
between bary_mul and bigsq.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-23 06:55:42 +00:00
nobu
4dbbcc48de
bignum.c: unnecessary check
...
* bignum.c (rb_cstr_parse_inum): remove unnecessary check.
successive sign is rejected by conv_digit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-07 08:31:03 +00:00
nobu
7ccae4d150
bignum.c: fix rb_cstr_parse_inum endp
...
* 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
2017-01-05 07:27:18 +00:00
nobu
c6eb59c439
bignum.c: precise fdiv
...
* bignum.c (big_fdiv): more precise calculation. [ruby-dev:49915]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-25 08:47:22 +00:00
nobu
6335fc6fe3
bignum.c (DBL_BIGDIG): make enum
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-25 08:42:28 +00:00
nobu
6839d47eb8
ruby.h: rb_big_sign
...
* 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
2016-11-19 04:32:52 +00:00
mrkn
06d701a1f0
rational.c: avoid needless object allocation with nurat_to_double
...
* 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
2016-11-11 15:55:30 +00:00
nobu
8baad2d31c
bignum.c: use RB_INTEGER_TYPE_P
...
* 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
2016-11-01 07:51:55 +00:00
nobu
4e44f6ef86
[DOC] replace Fixnum with Integer [ci skip]
...
* numeric.c: [DOC] update document for Integer class.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26 06:11:23 +00:00
usa
c2dd2d268e
* internal.h (ST2FIX): new macro to convert st_index_t to Fixnum.
...
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
2016-10-04 16:25:01 +00:00
nobu
772fd010b6
deprecate Fixnum and Bignum
...
* 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
2016-09-19 08:05:26 +00:00
naruse
236b5e9778
* bignum.c (rb_big2ulong): the old logic seems to try to avoid
...
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
2016-06-28 18:42:12 +00:00
nobu
c071c05229
Integer unification macro
...
* 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
2016-06-13 11:34:56 +00:00
akr
f9727c12cc
[Feature #12005 ] Unify Fixnum and Bignum into Integer
...
* [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
2016-05-17 06:53:48 +00:00
akr
c19c8ef4ae
[DOC]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 13:05:22 +00:00
akr
8248c26e6d
Define Integer#/ instead of Bignum#/.
...
* numeric.c (rb_int_div): Define Integer#/.
* bignum.c (rb_big_div): Don't define Bignum#/.
* lib/mathn.rb (Integer#/): Replace Integer#/ instead of Bignum#/.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 12:39:53 +00:00
akr
d0e2d150b8
Define Integer#+ instead of Bignum#+.
...
* numeric.c (rb_int_plus): Define Integer#+.
* bignum.c (rb_big_plus): Don't define Bignum#+.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 12:24:06 +00:00
akr
11ca96d3a3
Define Integer#- instead of Bignum#-.
...
* numeric.c (rb_int_minus): Define Integer#-.
* bignum.c (rb_big_minus): Don't define Bignum#-.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 12:09:31 +00:00
akr
a9f3a1cda1
Define Integer#* instead of Bignum#*.
...
* numeric.c (rb_int_mul): Define Integer#*.
* bignum.c (rb_big_mul): Don't define Bignum#*.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 11:54:26 +00:00
akr
e27a06f4bb
Define Integer#% instead of Bignum#%.
...
* numeric.c (rb_int_modulo): Define Integer#%.
* bignum.c (rb_big_modulo): Don't define Bignum#%.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 11:31:28 +00:00
akr
25f2c85066
Define Integer#== instead of Bignum#==.
...
* numeric.c (int_equal): Define Integer#==.
* bignum.c (rb_big_eq): Don't define Bignum#==.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 11:18:00 +00:00
akr
70279a5700
Define Integer#> instead of Bignum#>.
...
* numeric.c (int_gt): Define Integer#>.
* bignum.c (rb_big_gt): Don't define Bignum#>.
Renamed from big_gt.
* internal.h (rb_big_gt): Declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 10:42:06 +00:00
akr
289c3f40a1
Define Integer#>= instead of Bignum#>=.
...
* numeric.c (int_ge): Define Integer#>=.
* bignum.c (rb_big_ge): Don't define Bignum#>=.
Renamed from big_ge.
* internal.h (rb_big_ge): Declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 10:26:17 +00:00
akr
6b16db9c80
Define Integer#< instead of Bignum#<.
...
* numeric.c (int_lt): Define Integer#<.
* bignum.c (rb_big_lt): Don't define Bignum#<.
Renamed from big_lt.
* internal.h (rb_big_lt): Declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 10:10:23 +00:00
akr
d00bca92a9
Define Integer#<= instead of Bignum#<=.
...
* numeric.c (int_le): Define Integer#<=.
* bignum.c (rb_big_le): Don't define Bignum#<=.
Renamed from big_le.
* internal.h (rb_big_le): Declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 09:48:25 +00:00
akr
d13774e23f
Define Integer#GMP_VERSION.
...
* bignum.c (Init_Bignum): Define Integer#GMP_VERSION.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 09:12:11 +00:00
akr
635cff451f
Define Integer#remainder instead of Bignum#remainder.
...
* numeric.c (int_remainder): Define Integer#remainder.
* bignum.c (rb_big_remainder): Don't define Bignum#remainder.
* internal.h (rb_big_remainder): Declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 08:27:30 +00:00
akr
ae225a2ca8
{Fixnum,Bignum}#-@ is unified into Integer.
...
* numeric.c (rb_int_uminus): {Fixnum,Bignum}#-@ is unified into
Integer.
* bignum.c (rb_big_uminus): Don't define Bignum#-@.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 06:30:08 +00:00
akr
73dd745cf1
{Fixnum,Bignum}#div is unified into Integer.
...
* numeric.c (rb_int_idiv): {Fixnum,Bignum}#div is unified into
Integer.
* bignum.c (rb_big_idiv): Don't define Bignum#div.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 05:43:15 +00:00
akr
728333dcd3
{Fixnum,Bignum}#modulo is unified into Integer.
...
* numeric.c (rb_int_modulo): {Fixnum,Bignum}#modulo is unified into
Integer.
* bignum.c (rb_big_modulo): Don't define Bignum#modulo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 05:26:52 +00:00
akr
1b1a1ed6c8
{Fixnum,Bignum}#divmod is unified into Integer.
...
* numeric.c (int_divmod): {Fixnum,Bignum}#divmod is unified into
Integer.
* bignum.c (rb_big_divmod): Don't define Bignum#divmod.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30 05:05:54 +00:00
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
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
05bd6f8369
forgot to remove Bignum#bit_length.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-26 11:30:04 +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
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
3b6c4dad0c
bignum.c: rb_cstr_parse_inum
...
* 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
2016-04-08 17:05:12 +00:00
nobu
45c593d89e
bignum.c: radix check functions
...
* bignum.c (valid_radix_p, invalid_radix): extracted functions to
check radix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-08 08:32:25 +00:00
nobu
57638377cc
bignum.c: micro optimization
...
* 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
2016-03-20 10:09:14 +00:00
naruse
a2b4c6d1b1
* bignum.c (rb_big_cmp): reduce the code.
...
* 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
2016-03-19 19:48:26 +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
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
f8e79c84a9
* bignum.c (rb_big_hash): make it public function to be available in
...
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
2016-03-18 01:22:38 +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
mrkn
a3c9cda6d7
* bignum.c (rb_big_even_p, rb_big_odd_p): make them public functions
...
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
2016-03-17 17:07:29 +00:00
naruse
3d5a3a236d
* bignum.c (big2str_2bdigits): reduce div instruction.
...
Fix the code so that C compiler unify div instructions of `%` and `/`.
Before:
4291b0: 48 89 f0 mov %rsi,%rax
4291b3: 31 d2 xor %edx,%edx
4291b5: 48 83 ef 01 sub $0x1,%rdi
4291b9: 48 f7 f1 div %rcx # <---- !
4291bc: 41 0f b6 04 11 movzbl (%r9,%rdx,1),%eax
4291c1: 31 d2 xor %edx,%edx
4291c3: 41 88 04 38 mov %al,(%r8,%rdi,1)
4291c7: 48 63 4b 04 movslq 0x4(%rbx),%rcx
4291cb: 48 89 f0 mov %rsi,%rax
4291ce: 48 f7 f1 div %rcx # <---- !
4291d1: 48 89 c6 mov %rax,%rsi
4291d4: 48 85 ff test %rdi,%rdi
4291d7: 75 d7 jne 4291b0 <big2str_2bdigits+0x50>
4291d9: 48 63 6b 10 movslq 0x10(%rbx),%rbp
4291dd: 48 01 6b 20 add %rbp,0x20(%rbx)
4291e1: 48 8b 44 24 48 mov 0x48(%rsp),%rax
4291e6: 64 48 33 04 25 28 00 xor %fs:0x28,%rax
After:
4291b0: 48 63 73 04 movslq 0x4(%rbx),%rsi
4291b4: 31 d2 xor %edx,%edx
4291b6: 48 83 e9 01 sub $0x1,%rcx
4291ba: 48 f7 f6 div %rsi # <---- !
4291bd: 41 0f b6 14 10 movzbl (%r8,%rdx,1),%edx
4291c2: 88 14 0f mov %dl,(%rdi,%rcx,1)
4291c5: 48 85 c9 test %rcx,%rcx
4291c8: 75 e6 jne 4291b0 <big2str_2bdigits+0x50>
4291ca: 48 63 6b 10 movslq 0x10(%rbx),%rbp
4291ce: 48 01 6b 20 add %rbp,0x20(%rbx)
4291d2: 48 8b 44 24 48 mov 0x48(%rsp),%rax
4291d7: 64 48 33 04 25 28 00 xor %fs:0x28,%rax
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-14 10:14:48 +00:00
nobu
49079911ba
bignum.c: micro optimization
...
* bignum.c (rb_big_uminus, bigsub_int): use BIGNUM_NEGATE.
* internal.h (BIGNUM_NEGATE): simplify negation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-15 05:15:33 +00:00
nobu
174be80027
use particlar macros
...
* bignum.c: use particlar macros for positive/negative conditions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-15 05:09:59 +00:00
naruse
1f57a334da
* insns.def (opt_mult): Use int128_t for overflow detection.
...
* 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
2016-02-05 04:31:27 +00:00
nobu
439224a590
RUBY_ASSERT
...
* 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
2016-01-22 08:33:55 +00:00
nobu
bb4d72c51f
make local symbols static
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 15:07:41 +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
nobu
bbe805f09e
internal.h: roomof
...
* 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
2015-06-21 11:28:12 +00:00
nobu
61da10499f
bignum.c: doc of rb_cstr_to_inum
...
* bignum.c (rb_cstr_to_inum): [DOC] add document of the function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-17 12:11:53 +00:00
hsbt
d9a2b3480e
* doc/contributors.rdoc: fix a typo. Patch by @davydovanton
...
[fix GH-872][ci skip]
* doc/syntax/methods.rdoc: ditto.
* ext/digest/sha2/sha2.c: ditto.
* ext/socket/ipsocket.c: ditto.
* ext/tk/*: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-15 01:37:47 +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
akr
905b52217c
* bignum.c (bary_mul_balance_with_mulfunc): Fix free work area
...
location.
[ruby-dev:48723] [Bug #10464 ]
[ruby-core:66044] [Bug #10465 ]
Reported by Kohji Nishihama.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 08:13:30 +00:00
ngoto
9631e3e788
* bignum.c (absint_numwords_generic): set an array element after
...
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
2014-10-09 14:36:35 +00:00
nobu
aa3b506270
add some documents [ci skip]
...
* bignum.c (Init_Bignum): [DOC] Bignum::GMP_VERSION.
* complex.c (Init_Complex): [DOC] ignore an internal class.
* dir.c (Init_Dir): [DOC] File::FNM_SYSCASE.
* file.c (rb_file_exists_p): [DOC] File.exists? is deprecated.
* object.c (rb_mod_initialize_clone): [DOC] ignore implementation
detail.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-28 11:28:55 +00:00
akr
95de2b0012
* internal.h (struct RBignum): Use size_t for len.
...
* include/ruby/intern.h (rb_big_new): Use size_t instead of long to
specify the size of bignum.
(rb_big_resize): Ditto.
* bignum.c: Follow above changes.
* rational.c: Follow above changes.
* marshal.c: Follow above changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-19 01:11:04 +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
akr
9aa67e267b
* bignum.c (SIZEOF_BDIGIT): Renamed from SIZEOF_BDIGITS.
...
* internal.h: Ditto.
* marshal.c: Ditto.
* rational.c: Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-13 03:48:17 +00:00
nobu
3008ea2872
bignum.c: adjust condtions
...
* bignum.c (maxpow{16,32,64,128}_{exp,num}): adjust preprocessor
condtions to maxpow_in_bdigit_dbl().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14 01:27:44 +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
nobu
cc216f9aae
adjust indent and style
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:14 +00:00
mame
f67e09c7fd
* bignum.c (bary_mul_precheck): fix a copy-paste error.
...
Coverity Scan found this bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-21 16:23:58 +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
dfd26e3a47
* bignum.c (rb_big_cmp): Avoid bignum allocation for comparison
...
between bignum and fixnum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-15 02:48:44 +00:00
akr
6f8b0e9bb0
* include/ruby/intern.h,
...
include/ruby/io.h,
include/ruby/ruby.h,
include/ruby/win32.h,
include/ruby/backward/rubysig.h,
bignum.c,
gc.c,
io.c,
process.c,
safe.c,
struct.c,
thread.c,
ext/socket/rubysocket.h,
ext/-test-/old_thread_select: Remove deprecated definitions
[ruby-core:60581] [Feature #9502 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14 15:16:31 +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
akr
c1de2f4e3a
* bignum.c (rb_big_cmp): Specialize a comparison to zero.
...
* ext/bigdecimal/bigdecimal.c (is_negative): Use rb_big_cmp instead of
RBIGNUM_NEGATIVE_P.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-11 14:43:23 +00:00
akr
bc65d709ab
* bignum.c (bigxor_int): Apply BIGLO for long in a BDIGIT expression.
...
(bigor_int): Ditto.
(bigand_int): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-24 13:27:14 +00:00
akr
d33541009f
* include/ruby/defines.h: Don't use int128_t for Bignum.
...
It's not always faster.
* bignum.c: Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-24 04:51:33 +00:00
nobu
ef37d178bb
bignum.c: suppress warning
...
* bignum.c (absint_numwords_generic): suppress false warning in
rb_absint_numwords() by gcc 4.4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19 14:00:26 +00:00
nobu
e146015272
bignum.c, math.c: RB_BIGNUM_TYPE_P
...
* bignum.c, math.c (RB_BIGNUM_TYPE_P): predicate macro like
RB_FLOAT_TYPE_P.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:23 +00:00
nobu
c26293dccf
bignum.c, math.c: type predicates
...
* 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
2013-09-07 19:04:18 +00:00
nobu
a77ae1eced
bignum.c: split rb_big_fdiv and big_fdiv
...
* bignum.c (rb_big_fdiv): split with big_fdiv by divider type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:15 +00:00
akr
b1b395911c
* bignum.c (GMP_DIV_DIGITS): New macro.
...
(bary_divmod_gmp): New function.
(rb_big_divrem_gmp): Ditto.
(bary_divmod_branch): Ditto.
(bary_divmod): Use bary_divmod_branch.
(bigdivrem): Ditto.
* internal.h (rb_big_divrem_gmp): Declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 23:22:27 +00:00
akr
3b1ab2a6b7
* bignum.c (bary_divmod_normal): Reduce temporary array allocations.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 21:23:21 +00:00
akr
8745bc676e
* bignum.c (rb_big_divrem_normal): Add GC guards.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 17:21:43 +00:00
akr
8f8bf8243d
* bignum.c (rb_big_divrem_normal): New function.
...
* internal.h (rb_big_divrem_normal): Declared.
* ext/-test-/bignum/div.c: New file.
* test/-ext-/bignum/test_div.rb: New file.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 16:10:06 +00:00
akr
cf3736a75a
* bignum.c (bigdivrem_normal): Removed.
...
(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
2013-09-04 15:10:48 +00:00
akr
102a2c2e80
* bignum.c (bigdivrem): Useless declaration removed.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 14:03:29 +00:00
akr
dd95c9b1cd
* bignum.c (bigdivrem_normal): Add assertions.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 11:23:05 +00:00
akr
2583689340
* bignum.c (GMP_STR2BIG_DIGITS): New macro.
...
(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
2013-09-03 11:20:02 +00:00
akr
0b2413b471
* bignum.c (rb_str2big_poweroftwo): New function.
...
(rb_str2big_normal): Ditto.
(rb_str2big_karatsuba): Ditto.
* internal.h (rb_str2big_poweroftwo): Declared.
(rb_str2big_normal): Ditto.
(rb_str2big_karatsuba): Ditto.
* ext/-test-/bignum/str2big.c: New file.
* test/-ext-/bignum/test_str2big.rb: New file.
* ext/-test-/bignum/depend: Add the dependency for str2big.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-03 03:50:15 +00:00
akr
c048ad23b6
* bignum.c (str2big_scan_digits): Extracted from rb_cstr_to_inum.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-03 03:03:32 +00:00
akr
0c3d124571
* bignum.c (bytes_2comp): Define it only for little endian
...
environment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 22:41:07 +00:00
akr
1d7611ff48
* bignum.c (ISDIGIT): Unused macro removed.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 13:56:23 +00:00
akr
5f61a592e9
* bignum.c (str2big_poweroftwo): Extracted from rb_cstr_to_inum.
...
(str2big_normal): Ditto.
(str2big_karatsuba): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 13:52:05 +00:00
akr
0effd06122
* bignum.c (Init_Bignum): Define Bignum::GMP_VERSION when GMP is used.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 22:04:35 +00:00
akr
c48e169fb9
* bignum.c (big2str_generic): Reduce arguments.
...
(big2str_gmp): Ditto.
(rb_big2str1): Follow the above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 16:47:20 +00:00
akr
b64c2c348f
* bignum.c (GMP_BIG2STR_DIGITS): New constant.
...
(big2str_gmp): New function.
(rb_big2str1): Use big2str_gmp for big bignums.
* internal.h (rb_big2str_gmp): Declared.
* ext/-test-/bignum/big2str.c (big2str_gmp): New method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 14:34:53 +00:00
akr
4dd7a13a0a
* bignum.c (bary_mul_gmp): Use mpz_init and mpz_clear instead of
...
mpz_inits and mpz_clears.
Older GMP don't have them.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 13:38:49 +00:00
akr
7dd1604603
* bignum.c (big2str_base_poweroftwo): Renamed from
...
big2str_base_powerof2.
(rb_big2str_poweroftwo): New function for test.
(big2str_generic): Extracted from rb_big2str1.
(rb_big2str_generic): New function for test.
* internal.h (rb_big2str_poweroftwo): Declared.
(rb_big2str_generic): Ditto.
* ext/-test-/bignum/big2str.c: New file.
* test/-ext-/bignum/test_big2str.rb: New file.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 11:35:57 +00:00
akr
34004844cd
* bignum.c (big2str_2bdigits): Renamed from big2str_orig.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 06:21:52 +00:00
akr
6fe40011a8
* bignum.c: Remove BITSPERDIG >= INT_MAX test. The static assertion,
...
SIZEOF_BDIGITS <= sizeof(BDIGIT) is enough.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 04:03:32 +00:00
akr
c9b3571ceb
* bignum.c (maxpow_in_bdigit): Removed.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 02:39:05 +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
akr
a0a0b61b68
[DOC]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 01:00:15 +00:00
akr
7bb549d6b5
* internal.h (bit_length): Moved from bignum.c.
...
(nlz_int): Ditto.
(nlz_long): Ditto.
(nlz_long_long): Ditto.
(nlz_int128): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 00:57:00 +00:00
akr
8bd7af6794
* bignum.c (bit_length): Renamed from bitsize.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31 18:34:42 +00:00
akr
89744e75bd
* bignum.c (rb_big_bit_length): New method.
...
(rb_fix_bit_length): Ditto.
[ruby-core:56247] [Feature #8700 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31 15:09:20 +00:00
akr
83a0709174
* bignum.c: Use GMP to accelerate big Bignum multiplication.
...
(bary_mul_gmp): New function.
(bary_mul): Use bary_mul_gmp.
(bigsq): Use different threshold with GMP.
* configure.in: Detect GMP.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31 12:17:18 +00:00
akr
5a0e4a5871
* bignum.c (BARY_SHORT_MUL): Renamed from BARY_MUL1.
...
(bary_short_mul): Renamed from bary_mul1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-24 16:51:23 +00:00
akr
364237623b
* bignum.c (rb_big2str1): Make an expression more explicit.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-18 01:07:50 +00:00
akr
c106d19445
* bignum.c (rb_big2str1): Use power_level instead of bitsize(xn).
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-17 18:21:46 +00:00
akr
908e7312c4
* bignum.c (BIGDIVREM_EXTRA_WORDS): Redefine to 1.
...
(bigdivrem_num_extra_words): Removed.
(bigdivrem_normal): Simplefied.
(big2str_karatsuba): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-17 15:48:44 +00:00
akr
dcd4832d69
* bignum.c (bigdivrem_single1): Renamed from bigdivrem_single. Add
...
x_higher_bdigit argument.
(bigdivrem_single): Just call bigdivrem_single1.
(bigdivrem_restoring): Use bigdivrem_single1 to avoid memmove.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-16 01:11:18 +00:00
akr
9f6c62ad5f
* bignum.c (bary_small_rshift): Specify the higher BDIGIT instead of
...
sign bit.
(big_shift3): Follow the above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-16 00:19:51 +00:00
akr
d0b5d2016d
* bignum.c (bary_mul_toom3): Reduce a branch.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 17:24:41 +00:00
akr
6df786c79f
* bignum.c (bigdivrem_single): Use shift when y is a power of two.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 16:47:08 +00:00
akr
49e8387bae
* bignum.c (bigdivrem_restoring): Use bigdivrem_single if non-topmost
...
BDIGITs of y are zero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 16:16:08 +00:00
akr
7fc4142a02
* bignum.c (rb_big2str1): Truncate topmost zeros of x.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 15:36:00 +00:00
akr
02b6f663c5
* bignum.c (bary_divmod): Simplify an expression.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 15:03:35 +00:00
akr
942a3c9985
* bignum.c (bigdivrem_normal): Remove a local variable.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 15:01:38 +00:00
akr
d94fc786a4
* bignum.c (big2str_karatsuba): Use bigdivrem_restoring directly to
...
reduce working buffer and memory copy.
(rb_big2str1): Allocate working buffer for big2str_karatsuba here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 14:25:19 +00:00
akr
38be07f833
* bignum.c (bigdivrem_restoring): xn argument removed.
...
(bigdivrem_normal): Follow the above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-13 15:54:27 +00:00
akr
f069f26bc2
* bignum.c (big_div_struct): Remove xn and j field. Add zn field.
...
(bigdivrem1): Follow the above change.
(bigdivrem_restoring): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-13 15:21:42 +00:00
akr
26e69a89fa
* bignum.c (big_div_struct): ynzero field removed.
...
(bigdivrem1): Follow the above change.
(bigdivrem_restoring): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-13 14:43:10 +00:00
akr
adaa5650cd
* bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-13 14:03:55 +00:00
akr
06ed1c781a
* bignum.c (bitsize): Fix a conditional expression.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10 18:26:28 +00:00
akr
180d461a22
* bignum.c (big_div_struct): Use size_t.
...
(bigdivrem1): Ditto.
(bigdivrem_num_extra_words): Ditto.
(bigdivrem_single): Ditto.
(bigdivrem_normal): Ditto.
(bary_divmod): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-09 19:55:24 +00:00
nobu
ca3b9bbfe0
bignum.c: suppress warning
...
* bignum.c (rb_big_mul_karatsuba): suppress logical-op-parentheses
warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-09 13:41:23 +00:00
akr
fe6273975e
* bignum.c (rb_big_odd_p): Check the bignum length.
...
(rb_big_even_p): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07 11:08:03 +00:00
akr
ff84827eb6
* bignum.c (dbl2big): A condition simplified.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07 10:31:35 +00:00
akr
d35596c61d
* bignum.c (nlz16): Removed.
...
(nlz32): Ditto.
(nlz64): Ditto.
(nlz128): Ditto.
(nlz_int): New function.
(nlz_long): New function.
(nlz_long_long): New function.
(nlz_int128): New function.
(nlz): Follow above changes.
(bitsize): Follow above changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 22:43:01 +00:00
akr
25336fa7c1
* bignum.c (rb_big_realloc): Use VALGRIND_MAKE_MEM_UNDEFINED to
...
declare undefined memory area.
(bignew_1): Ditto.
* internal.h (VALGRIND_MAKE_MEM_DEFINED): Moved from gc.c
(VALGRIND_MAKE_MEM_UNDEFINED): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 03:26:34 +00:00
akr
2ae634f2f4
* bignum.c: Rename local variables.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-05 14:50:07 +00:00
akr
5a13ad0386
* bignum.c (BARY_TRUNC): New macro.
...
(bary_cmp): Use BARY_TRUNC.
(bary_mul_toom3): Ditto.
(bary_divmod): Ditto.
(abs2twocomp): Ditto.
(bigfixize): Ditto.
(rb_cstr_to_inum): Ditto.
(big2str_karatsuba): Ditto.
(bigdivrem): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 16:58:30 +00:00
akr
092511bac7
* bignum.c (big2str_karatsuba): Don't allocate new temporary buffer
...
if the buffer is enough for current invocation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 16:01:14 +00:00
nobu
b3be3c29c4
bignum.c: suppress warnings
...
* bignum.c (power_cache_get_power): declare as inline before call to
suppress warnings from gcc 4.2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 15:41:31 +00:00
akr
606a03dc59
* bignum.c (bary2bdigitdbl): New function.
...
(bdigitdbl2bary): Ditto.
(bary_mul_single): Use bdigitdbl2bary.
(power_cache_get_power): Ditto.
(bary_divmod): Use bary2bdigitdbl.
(big2str_orig): Ditto.
(bigdivrem): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 15:26:04 +00:00