aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* numeric.c: round_to_nearestnobu2016-08-151-7/+26
| | | | | | | * numeric.c (round_to_nearest): extract and reduce for platforms where round is not available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: infinite recursionnobu2016-08-131-21/+77
| | | | | | | * numeric.c (num_funcall0, num_funcall1): get rid of infinite recursion in fallback methods of Numeric. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c, complex.c: Add finite? and infinite? consistent with Floatmrkn2016-07-171-0/+30
| | | | | | | | | | | | | | | | | | | | | | * numeric.c (num_finite_p, num_infinite_p): Add Numeric#finite? and Numeric#infinite? [Feature #12039] [ruby-core:73618] * complex.c (rb_complex_finite_p): Add Complex#finite? * complex.c (rb_complex_infinite_p): Add Complex#infinite? * test/ruby/test_bignum.rb: Add test for Integer#finite? and Integer#infinite? * test/ruby/test_fixnum.rb: ditto. * test/ruby/test_rational.rb: Add test for Rational#finite? and Rational#infinite? * test/ruby/test_complex.rb: Add test for Complex#finite? and Complex#infinite? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: rb_complex prefixnobu2016-07-121-2/+2
| | | | | | | * complex.c (rb_complex_plus, rb_complex_mul): rename to rb_complex prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: round as doublenobu2016-07-081-2/+2
| | | | | | | * numeric.c (flo_round): compare as double, not long double with i387. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: round nearly middle valuenobu2016-07-071-2/+9
| | | | | | | | | * numeric.c (flo_round): [EXPERIMENTAL] adjust the case that the receiver is close to the exact but unrepresentable middle value of two values in the given precision. http://d.hatena.ne.jp/hnw/20160702 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: fix doc of Integer#digits [ci skip]nobu2016-06-141-2/+2
| | | | | | | * numeric.c: [DOC] fix rdoc directive, and an example of negative value. [ruby-core:76025] [Bug #12487] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: Add Integer#digits [Feature #12447] [ruby-core:75799]mrkn2016-06-131-0/+107
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Integer unification macronobu2016-06-131-0/+4
| | | | | | | | | | | * 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
* missing.h: isfinitenobu2016-05-231-8/+0
| | | | | | * include/ruby/missing.h (isfinite): move from numeric.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.h: RB_INTEGER_TYPE_Pnobu2016-05-181-3/+2
| | | | | | | | * 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
* Optimize enum_sum for a range from int to intmrkn2016-05-171-3/+3
| | | | | | | | | | | | | * enum.c (enum_sum): Optimize for a range from int to int. * test/ruby/test_enum.rb (test_range_sum): Move from test_range.rb, and add assertions for some conditions. * test/ruby/test_enum.rb (test_hash_sum): Move from test_hash.rb. * test/ruby/test_hash.rb, test/ruby/test_range.rb: Remove test_sum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use Integer instead of Fixnum and Bignum.akr2016-05-171-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | * object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, lib/rubygems/specification.rb, lib/uri/generic.rb, bootstraptest/test_eval.rb, basictest/test.rb, test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, test/csv/test_data_converters.rb, test/date/test_date.rb, test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, test/ruby/test_bignum.rb, test/ruby/test_case.rb, test/ruby/test_class.rb, test/ruby/test_complex.rb, test/ruby/test_enum.rb, test/ruby/test_eval.rb, test/ruby/test_iseq.rb, test/ruby/test_literal.rb, test/ruby/test_math.rb, test/ruby/test_module.rb, test/ruby/test_numeric.rb, test/ruby/test_range.rb, test/ruby/test_rational.rb, test/ruby/test_refinement.rb, test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [Feature #12005] Unify Fixnum and Bignum into Integerakr2016-05-171-23/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * [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
* drop FreeBSD < 4 supportnobu2016-05-121-8/+1
| | | | | | | | | | * NEWS: drop FreeBSD < 4 support. The most recent version affected by this is 3.5 and was released in 2000. https://www.freebsd.org/releases/3.5R/announce.html https://en.wikipedia.org/wiki/History_of_FreeBSD#Version_history git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: add -Wsuggest-attribute=noreturn and suppress warnings.naruse2016-05-081-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c: Remove prototype declarations to internal.hyui-knk2016-05-041-2/+0
| | | | | | | | | | | | | * numeric.c (fix_plus): Remove rb_nucomp_add prototype declaration. * numeric.c (fix_mul): Remove rb_nucomp_mul prototype declaration. * internal.h (rb_nucomp_add, rb_nucomp_mul): add prototype declarations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update result of 123456789 ** -2kazu2016-05-031-1/+1
| | | | | | | * numeric.c: [DOC] Update result of 123456789 ** -2. [ruby-dev:49606] [Bug #12339] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update rdoc of Integer#modulo [ci skip]kazu2016-05-021-3/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] merge documents for {Integer,Fixnum}#succ.akr2016-05-011-11/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC]akr2016-04-301-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Gather Fixnum method definitions.akr2016-04-301-14/+16
| | | | | | | | * numeric.c (Init_Numeric): Gather Fixnum method definitions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Define Integer#/ instead of Bignum#/.akr2016-04-301-1/+15
| | | | | | | | | | | | * 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
* Define Integer#+ instead of Bignum#+.akr2016-04-301-1/+3
| | | | | | | | | | * 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
* Define Integer#- instead of Bignum#-.akr2016-04-301-1/+3
| | | | | | | | | | * 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
* Define Integer#* instead of Bignum#*.akr2016-04-301-1/+3
| | | | | | | | | | * 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
* Define Integer#% instead of Bignum#%.akr2016-04-301-0/+1
| | | | | | | | | | * 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
* Define Integer#== instead of Bignum#==.akr2016-04-301-2/+18
| | | | | | | | | | * 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
* Define Integer#> instead of Bignum#>.akr2016-04-301-2/+16
| | | | | | | | | | | | | * 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
* Define Integer#>= instead of Bignum#>=.akr2016-04-301-2/+16
| | | | | | | | | | | | | * 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
* Define Integer#< instead of Bignum#<.akr2016-04-301-2/+16
| | | | | | | | | | | | | * 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
* Define Integer#<= instead of Bignum#<=.akr2016-04-301-2/+17
| | | | | | | | | | | | | * 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
* Define Integer#-@ instead of Fixnum#-@.akr2016-04-301-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Define Integer#remainder instead of Bignum#remainder.akr2016-04-301-0/+35
| | | | | | | | | | | | | * 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
* {Fixnum,Bignum}#-@ is unified into Integer.akr2016-04-301-4/+5
| | | | | | | | | | | * 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
* {Fixnum,Bignum}#div is unified into Integer.akr2016-04-301-4/+4
| | | | | | | | | | | * 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
* {Fixnum,Bignum}#modulo is unified into Integer.akr2016-04-301-2/+2
| | | | | | | | | | | * 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
* {Fixnum,Bignum}#divmod is unified into Integer.akr2016-04-301-4/+16
| | | | | | | | | | | * 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
* move Fixnum#/ document position.akr2016-04-301-9/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* {Fixnum,Bignum}#fdiv is unified into Integer.akr2016-04-301-3/+18
| | | | | | | | | | | * 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
* {Fixnum,Bignum}#** is unified into Integer.akr2016-04-301-4/+22
| | | | | | | | | | | * 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
* Rename fix_rev and rb_big_neg to fix_comp and rb_big_comp.akr2016-04-301-3/+3
| | | | | | | | | | * 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
* {Fixnum,Bignum}#~ is unified into Integer.akr2016-04-301-3/+23
| | | | | | | | | | | | | * 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
* {Fixnum,Bignum}#& is unified into Integer.akr2016-04-301-3/+15
| | | | | | | | | | | * 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
* {Fixnum,Bignum}#| is unified into Integer.akr2016-04-301-3/+15
| | | | | | | | | | | * 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
* {Fixnum,Bignum}#^ is unified into Integer.akr2016-04-271-3/+15
| | | | | | | | | | | * 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
* [Doc] Add Document-method: directives.akr2016-04-271-0/+24
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update rdoc of Integer#[] (fix -> int)kazu2016-04-271-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] move rdoc comments.akr2016-04-271-137/+151
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* {Fixnum,Bignum}#[] is unified into Integer.akr2016-04-271-15/+33
| | | | | | | | | | | | | * 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