mrkn
e7a7583029
rational.c: remove f_negative_p
...
* rational.c (f_negative_p): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 15:43:34 +00:00
mrkn
bdd18a2c31
rational.c: optimize Integer#lcm
...
* rational.c (f_div, f_mul, f_abs): optimize Integer#lcm
Author: Tadashi Saito <tad.a.digger@gmail.com>
* numeric.c (rb_int_abs): rename from int_abs to be exported.
* internal.h (rb_int_div, rb_int_abs): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 15:43:26 +00:00
mrkn
edfa67c248
rational.c: optimize (-rational).rationalize(some)
...
* rational.c (nurat_rationalize): optimize (-rational).rationalize(some).
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 15:43:18 +00:00
mrkn
a36d273eab
rational.c: define Rational#{negative?,positive?}
...
* rational.c (nurat_{negative,positive}_p): define Rational#negative?
and Rational#positive?, respectively.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 15:07:53 +00:00
mrkn
189ba5e0ac
rational.c: refactoring
...
* rational.c (id_expt, id_fdiv, f_expt, f_fdiv, f_positive_p): removed.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 14:54:19 +00:00
mrkn
cc376ee210
raitonal.c: remove needless macro
...
* rational.c (id_lshift, f_lshift): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 12:16:12 +00:00
mrkn
bdfd436f78
rational.c: optimize Float#rationalize
...
* rational.c (rb_flt_rationalize{,_with_prec},float_rationalize):
optimize Float#rationalize.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 12:14:10 +00:00
mrkn
81f16bf32f
rational.c: use rb_num_zerodiv instead of rb_raise_zerodiv
...
* rational.c (rb_raize_zerodiv): replace by rb_num_zerodiv.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 11:52:09 +00:00
mrkn
f40607d15d
rational.c: optimize Float#to_r
...
* rational.c (float_to_r): optimize Float#to_r.
* numeric.c (rb_int_lshift): exported.
* internal.h (rb_int_lshift): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 11:52:00 +00:00
mrkn
ffa2b0061f
rational.c: optimize Float#{numerator,denominator}
...
* rational.c (float_{numerator,denominator}): optimize
Float#{numerator,denominator}.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 11:51:51 +00:00
mrkn
ea5b76a079
rational.c: optimize Numeric#quo
...
* rational.c (numeric_quo): optimize Numeric#quo.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 11:51:41 +00:00
mrkn
04e83c536e
rational.c: refactor by removing needless ID vars
...
* rational.c (id_cmp, id_trunate): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 07:32:28 +00:00
mrkn
af070554e8
rational.c: optimize Rational#fdiv
...
* rational.c (nurat_fdiv): optimize Rational#fdiv.
Author: Tadashi Saito <tad.a.digger@gmail.com>
* rational.c (f_to_f, id_to_f): removed.
* rational.c (f_expt): only used when FLT_RADIX is not 2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 07:28:47 +00:00
mrkn
05ff2fe4f3
rational.c: optimize Rational#to_i
...
* rational.c (nurat_truncate): optimize Rational#to_i.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 06:58:35 +00:00
mrkn
9bb3022475
rational.c: optimize Rational#{floor,ceil,round,truncate}
...
* rational.c (f_{expt10,round_common},nurat_{floor,ceil,round_half_{up,even}}):
optimize Rational#{floor,ceil,round,truncate}.
Author: Tadashi Saito <tad.a.digger@gmail.com>
* numeric.c (rb_int_divmod): rename from int_divmod to be exported.
* numeric.c (rb_int_and): rename from int_and to be exported.
* intern.h (rb_int_{divmod,and}): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 06:45:11 +00:00
mrkn
a5160c5051
rational.c: optimize rational.coerce(float) and float [+-*/] rational
...
* rational.c (nurat_coerce): optimize rational.coerce(float).
note that this makes `float [+-*/] rational` faster
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 06:17:12 +00:00
mrkn
7e7778f80b
rational.c: optimize construction of Rational
...
* rational.c (nurat_{s_new_bang,canonicalize,f_rational,s_convert}):
optimize construction of Rational from numbers.
Author: Tadashi Saito <tad.a.digger@gmail.com>
* rational.c (read_{num,rat_nos}): optimize construction of Rational
from string.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 06:07:46 +00:00
mrkn
e5aa590637
rational.c: purge f_cmp
...
* rational.c (f_cmp, nurat_expt): purge f_cmp.
Author: Tadashi Saito <tad.a.digger@gmail.com>
* rational.c (INT_POSITIVE_P): added.
* numeric.c (FIXNUM_POSITIVE_P): move the definition into internal.h.
* internal.h (FIXNUM_POSITIVE_P): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 06:07:24 +00:00
mrkn
2e9357e7ea
rational.c: optimize Rational#-@
...
* rational.c (nurat_negate): introduced to optimize Rational#-@.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 06:07:01 +00:00
mrkn
d611a7c77b
rational.c: optimize Rational#==
...
* rational.c (nurat_eqeq_p): optimize Rational#==.
Author: Tadashi Saito <tad.a.digger@gmail.com>
* numeric.c (rb_int_equal): rename from int_equal and remove static
to be exported.
* internal.h (rb_int_equal): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 02:24:32 +00:00
mrkn
fb40c3776a
rational.c: optimize Rational#<=>
...
* rational.c (nurat_cmp): optimize Rational#<=>.
Author: Tadashi Saito <tad.a.digger@gmail.com>
* numeric.c (rb_int_cmp): rename from int_cmp and remove static
to be exported.
* internal.h (rb_int_cmp): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 01:29:01 +00:00
mrkn
d8769bffe5
rational.c: optimize Rational#**
...
* rational.c (nurat_expt): optimize Rational#**.
Author: Tadashi Saito <tad.a.digger@gmail.com>
* numeric.c (rb_float_pow): rename flo_pow() to rb_float_pow()
and remove static to be exporetd.
* internal.h (rb_int_pow, rb_float_pow): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 16:38:28 +00:00
mrkn
75bf28bb42
rational.c: add argument type check assertions in f_muldiv
...
* rational.c (f_muldiv): add assertions to check argument types
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 16:18:13 +00:00
mrkn
bc4310718b
rational.c: optimize Rational#/
...
* rational.c (f_muldiv, nurat_div): optimize Rational#/.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 16:17:56 +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
mrkn
8fd00809a7
rational.c: optimize rational * {float, huge rational, bignum}
...
* rational.c (f_muldiv, nurat_mul):
optimize rational * {float, huge rational, bignum}.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 15:11:04 +00:00
mrkn
86ec117881
rational.c: optimize rational - {float,rational}
...
* rational.c (f_addsub, nurat_sub): optimize rational - {float,rational}.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 14:57:11 +00:00
mrkn
b848f3c7e1
rational.c: optimize rational - integer
...
* rational.c (nurat_sub): optimize rational - integer.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 14:45:11 +00:00
mrkn
d028d6984f
rational.c: optimize rational + rational
...
* rational.c (f_addsub): optimize rational + rational.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 14:42:53 +00:00
mrkn
268203c5fc
rational.c: prevent unused warning
...
* rational.c (f_mod): define only when NDEBUG is not defined to prevent
unused warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 14:39:34 +00:00
mrkn
f64a53462e
numeric.c, rational.c: refactor by using FIXNUM_NEGATIVE_P and FIXNUM_ZERO_P
...
* numeric.c (num_zero_p, fix_divide, fix_mod, fix_divmod): refactor by using
FIXNUM_NEGATIVE_P and FIXNUM_ZERO_P.
* rational.c (INT_NEGATIVE_P, INT_ZERO_P): ditto.
* internal.h: move FIXNUM_NEGATIVE_P and FIXNUM_ZERO_P from numeric.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 14:39:25 +00:00
mrkn
8ee8c5eeb6
rational.c: optimize Integer#gcd.
...
* rational.c (f_gcd_normal): optimize Integer#gcd.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 14:39:16 +00:00
mrkn
dae15fa0d4
rational.c: optimize rational + integer.
...
* rational.c (rb_rational_plus): optimize rational + integer.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 14:39:07 +00:00
mrkn
70f5ad7c41
rational.c: optimize rational + float.
...
* rational.c (rb_rational_plus): optimize rational + float.
Author: Tadashi Saito <tad.a.digger@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 14:38:59 +00:00
nobu
e41ebc50dc
rational.c: check load
...
* rational.c (nurat_loader, nurat_marshal_load): check if loading
values are Integer. [ruby-core:78071] [Bug #12918 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 07:26:14 +00:00
nobu
0f9ce57b86
rational.c: optimize
...
* rational.c (f_{lt,eqeq,zero,one,minus_one,kind_of}_p): add RTEST
to results of funcalls.
* rational.c (f_negative_p, k_{integer,float,rational}_p):
optimize.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 07:08:53 +00:00
nobu
ac777fa1b8
rational.c: use RB_INTEGER_TYPE_P
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11 07:08:52 +00:00
mrkn
3e430c3a49
rational.c: optimize Rational#to_f by using rb_int_fdiv
...
* rational.c (nurat_to_f): optimize Rational#to_f by using rb_int_fdiv.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-10 15:23:43 +00:00
nobu
dfe91fcd08
numeric.c: round to nearest even
...
* numeric.c (flo_round, int_round): support round-to-nearest-even
semantics of IEEE 754 to match sprintf behavior, and add `half:`
optional keyword argument for the old behavior.
[ruby-core:76273] [Bug #12548 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 09:49:39 +00:00
nobu
c463366dfd
rb_funcallv
...
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
which are/will be/may be gems. [Fix GH-1406]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29 11:57:14 +00:00
nobu
4a9705d6e3
ruby.h: RB_INTEGER_TYPE_P
...
* include/ruby/ruby.h (RB_INTEGER_TYPE_P): new macro and
underlying inline function to check if the object is an
Integer (Fixnum or Bignum).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18 01:17:43 +00:00
mrkn
d1d95056a3
rename rb_rational_add -> rb_rational_plus
...
* rational.c (rb_rational_plus): rename from rb_rational_add
to be aligned with rb_fix_plus.
* array.c (rb_ary_sum): ditto.
* internal.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15 14:54:39 +00:00
mrkn
0a267b79f6
array.c (rb_ary_sum): use rb_rational_add directly
...
* rational.c (rb_rational_add): rename from nurat_add.
* array.c (rb_ary_sum): use rb_rational_add directly.
* test/ruby/test_array.rb (test_sum): add assertions for an array of
Rational values.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15 14:46:35 +00:00
nobu
f2cfd895c4
rational.c: pure declarations
...
* rational.c (get_dat1, get_dat2): turn into pure variable
declarations only, not mixed code and declarations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-30 01:27:03 +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
normal
bc8dfdc059
rational.c: preserve encoding in exception
...
* rational.c (string_to_r_strict): preserve encoding in exception
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-11 20:36:18 +00:00
svn
0e42b43497
* remove trailing spaces.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-30 08:02:56 +00:00
hsbt
f748c14cfd
* rational.c: Added documentation for rational literal.
...
[Bug #11075 ][fix GH-885][ci skip] Patch by @shishir127
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-30 08:02:38 +00:00
hsbt
82c55fced9
* rational.c: removed commented-out code.
...
[Feature #10376 ][ruby-core:65643]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-10 01:57:26 +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
nobu
9261f25e0f
provide backward compatibilities
...
* complex.c (Init_Complex): provide the feature for backward
compatibility.
* rational.c (Init_Rational): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-22 08:01:42 +00:00
akr
e56d2c385a
* include/ruby/ruby.h: Hide Rational internal.
...
(RRational): Moved to internal.h
(RRATIONAL): Ditto.
(RRATIONAL_SET_NUM): Moved to rational.c.
(RRATIONAL_SET_DEN): Ditto.
* rational.c (rb_rational_num): New function.
(rb_rational_den): Ditto.
* include/ruby/intern.h (rb_rational_num): Declared.
(rb_rational_den): Ditto.
* ext/bigdecimal/bigdecimal.c: Follow the above change.
* ext/date/date_core.c: Ditto.
[ruby-core:60665] [Feature #9513 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-17 16:37:41 +00:00
normal
a9befcdb08
avoid large alloca on Complex/Rational calls
...
* complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END
[Bug #9608 ]
* rational.c (read_digits): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-02 19:21:18 +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
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
hsbt
cbf4eca61e
* complax.c: [DOC] Document number conversion of `nil` by @skade [fix GH-570] [ci skip]
...
* object.c, rational.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-21 00:45:52 +00:00
nobu
6224216294
unused functions and variables
...
* complex.c, rational.c: remove unused functions, which are warned
by clang 5.1, and also variables only used by removed functions.
* ext/date/date_core.c: ditto.
* enc/utf_16be.c, enc/utf_16le.c: comment out constants only used
by commented out functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17 04:57:14 +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
tadf
41114caa4f
revertd.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-17 01:55:49 +00:00
naruse
90cdde870d
Revert r42942; a revert requires a reason
...
* rational.c (nurat_div): reverted r28844, r28886 and r28887.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-17 01:38:07 +00:00
tadf
bb82e49632
* complex.c: removed meaningless lines.
...
* rational.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-15 22:34:27 +00:00
tadf
2590279032
removed an empty line.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-15 21:48:27 +00:00
tadf
f663441bb5
* rational.c (nurat_div): reverted r28844, r28886 and r28887.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-15 04:42:19 +00:00
nobu
9c060a59b4
rational.c: conditionally defined variable
...
* rational.c (numeric_quo): variable 'canonicalization' is defined
conditionally by CANON (and CANONICALIZATION_FOR_MATHN).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-10 05:05:50 +00:00
nobu
2b5c2ebfbf
complex.c, rational.c: use RB_TYPE_P
...
* complex.c, rational.c: use RB_TYPE_P() for special classes instead
of switch with TYPE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-09 05:17:13 +00:00
akr
8953eee69f
* rational.c (f_gcd): Relax the condition to use GMP.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-08 07:02:42 +00:00
akr
42a3e0dc55
* rational.c: Include gmp.h if GMP is used.
...
(GMP_GCD_DIGITS): New macro.
(rb_gcd_gmp): New function.
(f_gcd_normal): Renamed from f_gcd.
(rb_gcd_normal): New function.
(f_gcd): Invoke rb_gcd_gmp or f_gcd_normal.
* internal.h (rb_gcd_normal): Declared.
(rb_gcd_gmp): Ditto.
* ext/-test-/rational: New directory.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-06 12:07:08 +00:00
mrkn
e06407cf7d
* rational.c (rb_flt_rationalize_with_prec): new public C function
...
to rationalize a Float instance with a precision.
* rational.c (rb_flt_rationalize): new public C function to
rationalize a Float instance. A precision is calculated from
the given float number.
* include/ruby/intern.h: Add rb_flt_rationalize_with_prec and
rb_flt_rationalize.
* parse.y: implement number literal suffixes, 'r' and 'i'.
[ruby-core:55096] [Feature #8430 ]
* bootstraptest/test_literal_suffix.rb: add tests for parser to scan
number literals with the above tsuffixes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 14:58:54 +00:00
nobu
8974d5aaa7
rational.c: ensure to be Rational
...
* rational.c (f_round_common): Rational is expected to be returned by
Rational#*, but mathn.rb breaks that assumption. [ruby-core:56177]
[Bug #8687 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 02:42:26 +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
nobu
4f66fb1442
rational.c: use existing functions
...
* rational.c (f_inspect, f_to_s): use existing functions, rb_inspect
and rb_obj_as_string respectively.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-29 23:57:25 +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
89e6910f04
* include/ruby/ruby.h: constify RRational::(num,den) and
...
RComplex::(real,imag).
Add macro to set these values:
* RRATIONAL_SET_NUM()
* RRATIONAL_SET_DEN()
* RCOMPLEX_SET_REAL()
* RCOMPLEX_SET_IMAG()
This change is a part of RGENGC branch [ruby-trunk - Feature #8339 ].
TODO: API design. RRATIONAL_SET(rat,num,den) is enough?
TODO: Setting constify variable with cast has same issue of r40691.
* complex.c, rational.c: use above macros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 15:55:09 +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
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
takano32
5e04bb6697
* rational.c: fix dangling if, else-if and else.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-12 08:00:16 +00:00
tadf
9a4f037502
* complex.c: edited rdoc.
...
* rational.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 08:01:32 +00:00
tadf
ec9eabc6c2
* complex.c: described syntax of string form.
...
* rational.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 00:18:52 +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
marcandre
8797ebd662
* rational.c (nurat_expt): Deal with special cases for rationals 0, ±1
...
[bug #5713 ] [bug #5715 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 05:39:33 +00:00
nobu
3d0786a3a8
marshal.c: marshal_dump instance varialbes
...
* marshal.c (w_object): dump instance varialbes of the result of
marshal_dump not the original object. [ruby-core:51163] [Bug #7627 ]
* complex.c (nucomp_marshal_dump): need to copy instance variables.
* rational.c (nurat_marshal_dump): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-26 13:39:15 +00:00
tadf
cbe5f8820b
* rational.c (f_round_common): should check overflow.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 09:25:13 +00:00
tadf
81af1bd9e8
* ratioanl.c (float_rationalize): reduced.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 09:01:22 +00:00
nobu
4d73f95068
random.c, rational.c: make marshal methods private
...
* random.c (Init_Random), rational.c (Init_Rational): make marshal
methods private. [Feature #6539 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03 10:10:14 +00:00
tadf
d6ec400148
* complex.c (string_to_c_strict, string_to_c): check NUL.
...
* rational.c (string_to_r_strict, string_to_r): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-22 11:32:52 +00:00
tadf
1ac4e6d274
* rational.c (read_digits): due to a bit tighter rb_cstr_to_inum().
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-21 09:48:51 +00:00
tadf
21453dc738
* complex.c: some improvements.
...
* rational.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 12:10:08 +00:00
tadf
42d38decda
* complex.c (read_comp): mathn compliant.
...
* rational.c (read_num): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-18 00:35:06 +00:00
tadf
7a1985a969
trivial changes.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-18 00:26:15 +00:00
tadf
47fe9b79a3
* complex.c (string_to_c_strict, string_to_c): rewrote without regexp.
...
* rational.c (string_to_r_strict, string_to_r): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-17 15:19:55 +00:00
tadf
e864787c84
* complex.c: modified doc.
...
* ratioanl.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-10 10:29:13 +00:00
tadf
d4199057bc
* complex.c: modified doc.
...
* rational.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-03 14:39:50 +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
nobu
003c45f9cd
complex.c, rational.c: compatible marshal loader
...
* complex.c, rational.c: compatible marshal loader for compatibilities
with 1.8. [ruby-core:45775] [Bug #6625 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-25 08:41:07 +00:00
tadf
eb6579e647
* marshal.c: experimental test aborted.
...
* complex.c: ditto.
* rational.c: ditto.
* include/ruby/intern.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 19:26:58 +00:00
tadf
f5b06413ca
* marshal.c: calls directly rb_{Complex,Rational}_marshal_load().
...
But now disabled. [experimental]
* complex.c: followed the above.
* rational.c: ditto.
* include/rub/intern.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 12:21:18 +00:00
nobu
694035eb35
use rb_marshal_{dump,load}
...
* marshal.c: revert r35879 "now marshal_{load|dump} are external."
* complex.c (nucomp_marshal__{dump,load}): should use rb_marshal_{dump,load}.
* rational.c (nurat_marshal__{dump,load}): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 07:34:03 +00:00
tadf
bdc55aa0c6
* complex.c: wrote Complex#_dump and Complex::load. But now
...
disabled (due to compatibility) [experimental].
* rational.c: wrote Rational#_dump and Rational::load. ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 05:05:29 +00:00
tadf
89ae71d721
* complex.c (nucomp_marshal_load): [ruby-core:45394]
...
* rational.c (nurat_marshal_load): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 01:26:41 +00:00
naruse
eeff98c430
* complex.c (nucomp_marshal_load): raise error on invalid data.
...
reported by John Firebaugh [ruby-core:42860] [Bug #6076 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-25 07:20:00 +00:00