summaryrefslogtreecommitdiff
path: root/rational.c
AgeCommit message (Collapse)Author
2016-11-12rational.c: purge f_cmpmrkn
* 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-12rational.c: optimize Rational#-@mrkn
* 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-12rational.c: optimize Rational#==mrkn
* 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-12rational.c: optimize Rational#<=>mrkn
* 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-11rational.c: optimize Rational#**mrkn
* 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-11rational.c: add argument type check assertions in f_muldivmrkn
* 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-11rational.c: optimize Rational#/mrkn
* 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-11rational.c: avoid needless object allocation with nurat_to_doublemrkn
* 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-11rational.c: optimize rational * {float, huge rational, bignum}mrkn
* 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-11rational.c: optimize rational - {float,rational}mrkn
* 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-11rational.c: optimize rational - integermrkn
* 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-11rational.c: optimize rational + rationalmrkn
* 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-11rational.c: prevent unused warningmrkn
* 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-11numeric.c, rational.c: refactor by using FIXNUM_NEGATIVE_P and FIXNUM_ZERO_Pmrkn
* 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-11rational.c: optimize Integer#gcd.mrkn
* 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-11rational.c: optimize rational + integer.mrkn
* 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-11rational.c: optimize rational + float.mrkn
* 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-11rational.c: check loadnobu
* 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-11rational.c: optimizenobu
* 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-11rational.c: use RB_INTEGER_TYPE_Pnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-10rational.c: optimize Rational#to_f by using rb_int_fdivmrkn
* 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-05numeric.c: round to nearest evennobu
* 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-07-29rb_funcallvnobu
* *.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-05-18ruby.h: RB_INTEGER_TYPE_Pnobu
* 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-04-15rename rb_rational_add -> rb_rational_plusmrkn
* 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-15array.c (rb_ary_sum): use rb_rational_add directlymrkn
* 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-03-30rational.c: pure declarationsnobu
* 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-01-22RUBY_ASSERTnobu
* 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
2015-09-11rational.c: preserve encoding in exceptionnormal
* 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-04-30* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-30* rational.c: Added documentation for rational literal.hsbt
[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-01-10* rational.c: removed commented-out code.hsbt
[Feature #10376][ruby-core:65643] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-22provide backward compatibilitiesnobu
* 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-05-17* include/ruby/ruby.h: Hide Rational internal.akr
(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-02avoid large alloca on Complex/Rational callsnormal
* 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-04-19* internal.h (struct RBignum): Use size_t for len.akr
* 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-13* bignum.c (SIZEOF_BDIGIT): Renamed from SIZEOF_BDIGITS.akr
* 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-03-21* complax.c: [DOC] Document number conversion of `nil` by @skade [fix ↵hsbt
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-17unused functions and variablesnobu
* 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-02-15* internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.akr
(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
2013-09-17revertd.tadf
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-17Revert r42942; a revert requires a reasonnaruse
* 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-15 * complex.c: removed meaningless lines.tadf
* rational.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-15removed an empty line.tadf
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-15 * rational.c (nurat_div): reverted r28844, r28886 and r28887.tadf
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-10rational.c: conditionally defined variablenobu
* 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-09complex.c, rational.c: use RB_TYPE_Pnobu
* 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-08* rational.c (f_gcd): Relax the condition to use GMP.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-06* rational.c: Include gmp.h if GMP is used.akr
(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