summaryrefslogtreecommitdiff
path: root/numeric.c
AgeCommit message (Collapse)Author
2016-04-18numeric.c: update doc [ci skip]nobu
* numeric.c (int_to_i): [DOC] floor and ceil are no longer synonyms. [Feature #12245] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13numeric.c: flo_ceilnobu
* numeric.c (flo_ceil): add an optional parameter, digits, as well as Float#round. [Feature #12245] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13numeric.c: flo_floornobu
* numeric.c (flo_floor): add an optional parameter, digits, as well as Integer#floor. [Feature #12245] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13numeric.c: int_ceilnobu
* numeric.c (int_ceil): add an optional parameter, digits, as well as Integer#round. [Feature #12245] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13numeric.c: int_floornobu
* numeric.c (int_floor): add an optional parameter, digits, as well as Integer#round. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13numeric.c: int_round_zero_pnobu
* 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-13numeric.c: float_invariant_roundnobu
* numeric.c (float_invariant_round): extracted from flo_round to be optimizer-friendly, e.g., tail-call optimization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-03numeric.c: dbl2ival no longer roundsnobu
* numeric.c (flodivmod): round division if it is a finite number and module is required. * numeric.c (dbl2ival): do not round here. * numeric.c (flo_ceil): use dbl2ival. * numeric.c (flo_round): round explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-02numeric.c: move declaration [ci skip]nobu
* numeric.c (fix_lshift, fix_rshift, flo_truncate): move forward declaration to the top. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-02numeric.c: prefer rb_check_aritynobu
* numeric.c (flo_round, int_to_s, int_round): use rb_check_arity instead of rb_scan_args for a simple optional argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-28* numeric.c (int_pos_p): fix typos.kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-26numeric.c: rb_int2strnobu
* numeric.c (rb_int2str): conversion function to String for generic Integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-26numeric.c: rb_int_roundnobu
* numeric.c (rb_int_round): rounding function for generic Integers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-26numeric.c: basic arithmeticnobu
* numeric.c (rb_int_{uminus,plus,minus,mul,idiv,modulo}): basic arithmetic functions for generic Integers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-26numeric.c: Fixnum predictsnobu
* numeric.c (FIXNUM_{POSITIVE,NEGATIVE,ZERO}_P): predict macros only for Fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21* internal.h (rb_fix_divmod_fix): like r54213, use FIX2NUM only ifnaruse
x == FIXNUM_MIN && y == -1. This must be a rare case and it is expected compiler to handle well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-20* internal.h (DLONG): defined if long is 32bit (and LONG_LONG is 64bit;naruse
but LONG_LONG is always defined as 64bit), or there's int128_t. * internal.h (DL2NUM): defined if DLONG is defined. * internal.h (rb_fix_mul_fix): defined for `Fixnum * Fixnum`. * insns.def (opt_mul): use rb_fix_mul_fix(). * numeric.c (fix_mul): ditto. * time.c (mul): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-20numeric.c: optimize Fixnum<->Bignum comparisonsnobu
* numeric.c (fix_gt, fix_ge, fix_lt, fix_le): optimize comparisons Fixnum against Bignum by rb_big_cmp in inversed order without new Bignum instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19fix r54193nobu
* numeric.c (fix_cmp): invert the result as the comarison is inverted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19* numeric.c (fix_cmp): use rb_big_cmp if x is Fixnum and y is Bignum.naruse
rb_big_cmp handles such case smartly with big_norm. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19* numeric.c (int_to_f): raise NotImplementedError when a receivermrkn
class is unknown. * test/-ext-/integer/test_my_integer.rb (test_my_integer_to_f): modify a test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19* bignum.c (Bignum#<=>): remove it because they are unified withmrkn
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-18* bignum.c (rb_big_to_f, Bignum#to_f): removed them because they aremrkn
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* numeric.c (int_to_f, fix_to_f): rename fix_to_f to int_to_f, and addmrkn
treatment for subclasses which don't have definitions of to_f method. * numeric.c (Integer#to_f, Fixnum#to_f): move to_f method from Fixnum to Integer. * ext/-test-/integer/my_integer.rb: define helper class for testing to_f method for a subclass of Integer. * ext/-test-/integer/extconf.rb: ditto. * ext/-test-/integer/init.c: ditto. * test/-ext-/integer/test_my_integer.rb: examine to_f method for a subclass of Integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18* bignum.c (Bignum#eql?): remove its definition because it is unifiedmrkn
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* bignum.c (rb_big_to_s, Bignum#to_s): remove its definition becausemrkn
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* numeric.c (int_to_s): Move from flo_to_s.mrkn
* numeric.c (Integer#to_s): Move from Fixnum#to_s. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17* numeric.c (fix_zero_p, fix_even_p, fix_odd_p): remove needlessmrkn
functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17* numeric.c (int_even_p): treat Fixnum and Bignum values directly.mrkn
I forgot include this commit in the previous one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17* bignum.c (Bignum#even?, Bignum#odd?): remove definitionsmrkn
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* numeric.c (num_step): use rb_equal for zero check. rb_num_coerce_cmpmame
created an object which caused extra overhead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17* enum.c (enum_inject): Implement the specialized code for sum ofakr
integers including Bignums. * internal.h (rb_fix_plus): Declared to be usable from enum_inject. * numeric.c (rb_fix_plus): Defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-14* numeric.c (fix2str): improve r54092 like rb_int2big().naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-13numeric.c: fix edge casenobu
* numeric.c (rb_fix2str): fix edge case, accidentally generated wrong Fixnum from LONG_MIN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-08* intern.h (rb_divmod): assume compilers `/` and `%` comply C99naruse
and reduce branching. If a compiler doesn't comply, add #ifdefs. * intern.h (rb_div): added for Ruby's behavior. * intern.h (rb_mod): added for Ruby's behavior. * insns.def (opt_div): use rb_div. * insns.def (opt_mod): use rb_mod. * numeric.c (fixdivmod): removed. * numeric.c (fix_divide): use rb_div. * numeric.c (fix_mod): use rb_mod. * numeric.c (fix_divmod): use rb_divmod. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-26numeric.c: wrong type step should raise TypeErrornobu
* numeric.c (num_step_scan_args): comparison String with Numeric should raise TypeError. it is an invalid type, but not a mismatch the number of arguments. [ruby-core:62430] [Bug #9810] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-24numeric.c: micro optimizationsnobu
* numeric.c (flo_to_s, rb_fix2str): use rb_usascii_str_new instead of rb_usascii_str_new_cstr, when the length can be calculated. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-17numeric.c: adjust typesnobu
* numeric.c (coerce_rescue, coerce_rescue_quiet): rescue functions should have errinfo too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-17numeric.c: adjust typesnobu
* numeric.c (coerce_body, coerce_rescue, coerce_rescue_quiet): adjust parameter types for rb_rescue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-16numeric.c: fix segfaultnobu
* numeric.c (compare_with_zero): fix variable name, rb_cmperr requires VALUEs but not an ID. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14* enum.c: fix a typo in documentation.hsbt
[ci skip][fix GH-1140] Patch by @jutaz * io.c: ditto. * iseq.c: ditto. * numeric.c: ditto. * process.c: ditto. * string.c: ditto. * vm_trace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-18* numeric.c: Good-by Borland-C.kosaki
* include/ruby/backward/rubyio.h: ditto. * include/ruby/backward/st.h: ditto. * include/ruby/backward/util.h: ditto. * include/ruby/backward/rubysig.h: ditto. * include/ruby/backward/classext.h: ditto. * dln.c: ditto. * gc.c: ditto. * win32/resource.rb: ditto. * win32/dir.h: ditto. * ext/tk/tcltklib.c: ditto. * NEWS: announce that Borland-C is no longer supported. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12numeric.c: use predefined IDsnobu
* numeric.c: use predefined IDs and prepared IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12numeric.c: common expressionsnobu
* numeric.c (flo_pow): extract common expressions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10* vm_eval.c, internal.h (rb_yield_1): added for performance whichko1
doesn't check Qundef. * numeric.c (int_dotimes): use rb_yield_1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05* numeric.c: [DOC] Overview for Numeric class by Joe Corcoranzzak
This patch was created at ROSSConf Berlin 2015 [Bug #11555] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28preserve encodings in error messagesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11* numeric.c (Init_Numeric): Fix document for Float::MIN andakr
Float::EPSILON. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22fix doc for Numeric#coerce [ci skip]nobu
* numeric.c (num_coerce): [DOC] fix doc for Numeric#coerce, missing '+'. [Fix GH-974] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e