summaryrefslogtreecommitdiff
path: root/numeric.c
AgeCommit message (Collapse)Author
2016-11-10numeric.c, internal.h: export int_fdiv() as rb_int_fdiv()mrkn
* numeric.c (rb_int_fdiv): export int_fdiv() as rb_int_fdiv(). * internal.h (rb_int_fdiv): add declaration of rb_int_fdiv(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-07 Introduce table improvement by Vladimir Makarov <vmakarov@redhat.com>.ko1
[Feature #12142] See header of st.c for improvment details. You can see all of code history here: <https://github.com/vnmakarov/ruby/tree/hash_tables_with_open_addressing> This improvement is discussed at <https://bugs.ruby-lang.org/issues/12142> with many people, especially with Yura Sokolov. * st.c: improve st_table. * include/ruby/st.h: ditto. * internal.h, numeric.c, hash.c (rb_dbl_long_hash): extract a function. * ext/-test-/st/foreach/foreach.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05numeric.c: raise TypeError at wrong argumentnobu
* numeric.c (int_pos_p, int_neg_p): raise TypeError if not an Integer instead of returning nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05* numeric.c (rb_int_round): cast to SIGNED_VALUE to suppressshugo
warnings by -Wsign-compare. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56601 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-11-04numeric.c (rb_int_digits): Fix exception messagemrkn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-01numeric.c: bit op with non-integernobu
* numeric.c (rb_num_coerce_bit): enable bit operations with coercing by non-integer object. [ruby-core:77783] [Bug #12875] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-01numeric.c: use rb_num_coerce_bitnobu
* numeric.c (int_and, int_or, int_xor): use rb_num_coerce_bit to reduce repeated code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-01numeric.c: fix return value on big 0nobu
* numeric.c (num_zero_p): should return true if zero. rb_bigzero_p returns 1 or 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-01numeric.c: adjust indent [ci skip]nobu
* numeric.c (rb_num2ulong_internal): adjust indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-01numeric.c: fix typos [ci skip]nobu
* numeric.c (rb_num2ulong_internal, rb_num2ull): fix typos in comments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* 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-22numeric.c: fix up r55891nobu
* numeric.c (num_funcall1): check recursion by inverse pair, to fix fake infinite recursion. [ruby-core:77713] [Bug #12864] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-04* internal.h (ST2FIX): new macro to convert st_index_t to Fixnum.usa
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-02numeric.c: adjust typenobu
* numeric.c (rb_fix2str): cast to a pointer to adjust argument type for the format. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-01* numeric.c (rb_fix2str): detect unnormalized Fixnum value.usa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-24fid typos [ci skip]nobu
* fix typos, "a" before "Integer" to "an". [Fix GH-1438] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-19deprecate Fixnum and Bignumnobu
* 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-08-15numeric.c: round_to_nearestnobu
* 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
2016-08-13numeric.c: infinite recursionnobu
* 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
2016-07-17numeric.c, complex.c: Add finite? and infinite? consistent with Floatmrkn
* 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
2016-07-12complex.c: rb_complex prefixnobu
* 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
2016-07-08numeric.c: round as doublenobu
* 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
2016-07-07numeric.c: round nearly middle valuenobu
* 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
2016-06-14numeric.c: fix doc of Integer#digits [ci skip]nobu
* 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
2016-06-13numeric.c: Add Integer#digits [Feature #12447] [ruby-core:75799]mrkn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-13Integer unification macronobu
* 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-05-23missing.h: isfinitenobu
* 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
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-05-17Optimize enum_sum for a range from int to intmrkn
* 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
2016-05-17Use Integer instead of Fixnum and Bignum.akr
* 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
2016-05-17[Feature #12005] Unify Fixnum and Bignum into Integerakr
* [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-12drop FreeBSD < 4 supportnobu
* 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
2016-05-08* configure.in: add -Wsuggest-attribute=noreturn and suppress warnings.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-04numeric.c: Remove prototype declarations to internal.hyui-knk
* 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
2016-05-03Update result of 123456789 ** -2kazu
* 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
2016-05-02Update rdoc of Integer#modulo [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-01[DOC] merge documents for {Integer,Fixnum}#succ.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30[DOC]akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-30Gather Fixnum method definitions.akr
* 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
2016-04-30Define Integer#/ instead of Bignum#/.akr
* 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-30Define Integer#+ instead of Bignum#+.akr
* 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-30Define Integer#- instead of Bignum#-.akr
* 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-30Define Integer#* instead of Bignum#*.akr
* 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-30Define Integer#% instead of Bignum#%.akr
* 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-30Define Integer#== instead of Bignum#==.akr
* 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-30Define Integer#> instead of Bignum#>.akr
* 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-30Define Integer#>= instead of Bignum#>=.akr
* 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-30Define Integer#< instead of Bignum#<.akr
* 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-30Define Integer#<= instead of Bignum#<=.akr
* 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