summaryrefslogtreecommitdiff
path: root/numeric.c
AgeCommit message (Collapse)Author
2021-03-12Fix integer/float remainder with infinity argument of opposite signJeremy Evans
Previously, the result was incorrect: 4.remainder(-Float::INFINITY) Before: => NaN After: => 4 4.2.remainder(-Float::INFINITY) Before: => NaN After: => 4.2 Fixes [Bug #6120] Notes: Merged: https://github.com/ruby/ruby/pull/4257
2021-02-19Improve performance some Numeric methods [Feature #17632] (#4190)S.H
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2021-02-08Improve performance Float#positive? and Float#negative? [Feature #17614] (#4160)S.H
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2021-01-31Move rb_big_isqrt declarationS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4135
2021-01-18Fix JIT link failuresTakashi Kokubun
forgotten in https://github.com/ruby/ruby/pull/4018
2021-01-01Improve performance some Float methods [Feature #17498] (#4018)S.H
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-12-22Allow inlining Integer#-@ and #~Takashi Kokubun
``` $ benchmark-driver -v --rbenv 'before --jit;after --jit' benchmark/mjit_integer.yml --filter '(comp|uminus)' before --jit: ruby 3.0.0dev (2020-12-23T05:41:44Z master 0dd4896175) +JIT [x86_64-linux] after --jit: ruby 3.0.0dev (2020-12-23T06:25:41Z master 8887d78992) +JIT [x86_64-linux] last_commit=Allow inlining Integer#-@ and #~ Calculating ------------------------------------- before --jit after --jit mjit_comp(1) 44.006M 70.417M i/s - 40.000M times in 0.908967s 0.568042s mjit_uminus(1) 44.333M 68.422M i/s - 40.000M times in 0.902255s 0.584603s Comparison: mjit_comp(1) after --jit: 70417331.4 i/s before --jit: 44005980.4 i/s - 1.60x slower mjit_uminus(1) after --jit: 68422468.8 i/s before --jit: 44333371.0 i/s - 1.54x slower ```
2020-12-14Move docs for Integer#bit_length [ci skip]Alan Wu
2020-12-12Remove unused function declarationsS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/3886
2020-12-09Fix ArithmeticSequence#last and ArithmeticSequence#each for non-integer ↵Kenta Murata
sequences (#3870) [Bug #17218] [ruby-core:100312] Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2020-11-20renameS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/3769
2020-11-20fix codeS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/3769
2020-11-20add flo_prev_or_next funcS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/3769
2020-10-23numeric.c, range.c: prohibit zero stepKenta Murata
* numeric.c: prohibit zero step in Numeric#step * range.c: prohibit zero step in Range#step * Fix ruby-spec [Feature #15573] Notes: Merged: https://github.com/ruby/ruby/pull/3689 Merged-By: mrkn <mrkn@ruby-lang.org>
2020-10-21Don't redefine #rb_intern over and over againStefan Stüben
Notes: Merged: https://github.com/ruby/ruby/pull/3589
2020-10-02Hoisted out ensure_cmp which checks the comparison succeededNobuyoshi Nakada
2020-10-02Ensure that the comparison succeeded [Bug #17205]Nobuyoshi Nakada
2020-09-30Fix unsigned int overflow in error message for chrPeter Zhu
The error message has an integer overflow because it treats an unsigned int as a signed int. Before: ``` > 3_000_000_000.chr -1294967296 out of char range (RangeError) ``` After: ``` > 3_000_000_000.chr 3000000000 out of char range (RangeError) ``` Redmine ticket: https://bugs.ruby-lang.org/issues/17186 Notes: Merged: https://github.com/ruby/ruby/pull/3602
2020-08-05[DOC] Use oracle url instead of sun urlS-H-GAMELINKS
[ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/3389
2020-07-28Use https instead of httpKazuhiro NISHIYAMA
2020-07-13fix MJIT link error卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/3305
2020-07-13inline Primitive.cexpr!卜部昌平
We can obtain the verbatim source code of Primitive.cexpr!. Why not paste that content into the JITed program. Notes: Merged: https://github.com/ruby/ruby/pull/3305
2020-06-29add UNREACHABLE_RETURN卜部昌平
Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29fix_pow: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29int_pow: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29flo_to_s: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-27Mark some Integer methods as inline (#3264)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-20Make Integer#zero? a separated method and builtin (#3226)Takashi Kokubun
A prerequisite to fix https://bugs.ruby-lang.org/issues/15589 with JIT. This commit alone doesn't make a significant difference yet, but I thought this commit should be committed independently. This method override was discussed in [Misc #16961]. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-16Remove unused else if statements in int_even_p func (#3220)S.H
* remove else if & rb_funcall * fix int_even_p impl * fix rb_int_odd_p implementation Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-06-16Add static modifier for rb_int_ceil & rb_int_floor (#3217)S.H
Notes: Merged-By: ko1 <ko1@atdot.net>
2020-05-12numeric.c: optimize `float ** 2` case by fastpathYusuke Endoh
It would be a relatively frequent case. It is still slower than `float * float` because `*` has a dedicated VM instruction (opt_mult), though.
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11Added more NORETURN declarationsNobuyoshi Nakada
2020-04-09numeric.c: Remove unreachable codeYusuke Endoh
b cannot be <= 0 here. Found by Coverity Scan
2020-04-08Suppress C4244 "possible loss of data" warningsNobuyoshi Nakada
2020-04-08Suppress -Wswitch warningsNobuyoshi Nakada
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2020-03-21Removed non-RUBY_INTEGER_UNIFICATION codeNobuyoshi Nakada
2020-03-09Remove Float::ROUNDSJeremy Evans
Fixes [Bug #16044] Notes: Merged: https://github.com/ruby/ruby/pull/2953
2020-01-27Check the encoding of `half:` optionNobuyoshi Nakada
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26add several __has_something macro卜部昌平
With these macros implemented we can write codes just like we can assume the compiler being clang. MSC_VERSION_SINCE is defined to implement those macros, but turned out to be handy for other places. The -fdeclspec compiler flag is necessary for clang to properly handle __has_declspec(). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-11-19make functions static卜部昌平
These functions are used from within a compilation unit so we can make them static, for better binary size. This changeset reduces the size of generated ruby binary from 26,590,128 bytes to 26,584,472 bytes on my macihne. Notes: Merged: https://github.com/ruby/ruby/pull/2682
2019-11-07Use FIX2LONG instead of FIX2INT like 26843cbcd0NARUSE, Yui
2019-11-07Use FIX2LONG to avoid unexpected exceptionNARUSE, Yui
Though it won't happen in the real world in this context, FIX2INT may raise an exception and it cause to generate extra code.
2019-09-30Suppress keyword argument warning from #stepNobuyoshi Nakada
* numeric.c (num_step): pass the extracted argument from keyword argument, not the last argument itself which should have been warned already.
2019-08-25Inspect dynamic symbol as well as static symbolNobuyoshi Nakada
2019-08-10Expanded f_quoNobuyoshi Nakada
2019-08-07Deprecate Float::ROUNDS, which should not be a constantNobuyoshi Nakada
[Bug #16044]