aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* Make Float#floor with ndigits argument handle errorJeremy Evans2021-07-271-3/+7
| | | | | | | | | | | | | | The previous implementation could result in a returned float that is 1/(10**ndigits) too low. First try adding one before dividing, and if that results in a value that is greater than the initial number, then try the original calculation. Spec added for ciel, but the issue doesn't appear to affect ciel, at least not for the same number. If the issue does effect ciel, a similar fix could probably work for it. Fixes [Bug #18018]
* Add Integer.try_convert [Feature #15211]Nobuyoshi Nakada2021-07-161-0/+7
|
* What's Here for Numeric and ComparableBurdette Lamar2021-06-211-0/+80
|
* Improve perfomance for Integer#size method [Feature #17135] (#3476)S.H2021-06-041-19/+2
| | | | | | | | | * Improve perfomance for Integer#size method [Feature #17135] * re-run ci * Let MJIT frame skip work for Integer#size Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* Fix Enumerator::ArithmeticSequence handling of float rangesJeremy Evans2021-05-291-2/+18
| | | | | | | | | | Depending on the float range, there could be an off-by-one error, where the last result that should be in the range was missed. Fix this by checking if the computed value for the expected value outside the range is still inside the range, and if so, increment the step size. Fixes [Bug #16612]
* Refactor num_zero_p function (#4522)S.H2021-05-231-4/+1
|
* Fix integer/float remainder with infinity argument of opposite signJeremy Evans2021-03-121-3/+8
| | | | | | | | | | | | | | 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]
* Improve performance some Numeric methods [Feature #17632] (#4190)S.H2021-02-191-58/+0
|
* Improve performance Float#positive? and Float#negative? [Feature #17614] (#4160)S.H2021-02-081-30/+0
|
* Move rb_big_isqrt declarationS-H-GAMELINKS2021-01-311-2/+0
|
* Fix JIT link failuresTakashi Kokubun2021-01-181-8/+2
| | | | forgotten in https://github.com/ruby/ruby/pull/4018
* Improve performance some Float methods [Feature #17498] (#4018)S.H2021-01-011-53/+1
|
* Allow inlining Integer#-@ and #~Takashi Kokubun2020-12-221-30/+4
| | | | | | | | | | | | | | | | | | | | | | ``` $ 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 ```
* Move docs for Integer#bit_length [ci skip]Alan Wu2020-12-141-45/+0
|
* Remove unused function declarationsS-H-GAMELINKS2020-12-121-4/+0
|
* Fix ArithmeticSequence#last and ArithmeticSequence#each for non-integer ↵Kenta Murata2020-12-091-24/+29
| | | | | | sequences (#3870) [Bug #17218] [ruby-core:100312]
* renameS-H-GAMELINKS2020-11-201-3/+3
|
* fix codeS-H-GAMELINKS2020-11-201-14/+4
|
* add flo_prev_or_next funcS-H-GAMELINKS2020-11-201-8/+21
|
* numeric.c, range.c: prohibit zero stepKenta Murata2020-10-231-3/+6
| | | | | | | | | * numeric.c: prohibit zero step in Numeric#step * range.c: prohibit zero step in Range#step * Fix ruby-spec [Feature #15573]
* Don't redefine #rb_intern over and over againStefan Stüben2020-10-211-6/+3
|
* Hoisted out ensure_cmp which checks the comparison succeededNobuyoshi Nakada2020-10-021-9/+13
|
* Ensure that the comparison succeeded [Bug #17205]Nobuyoshi Nakada2020-10-021-1/+3
|
* Fix unsigned int overflow in error message for chrPeter Zhu2020-09-301-1/+1
| | | | | | | | | | | | | | | | | | 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
* [DOC] Use oracle url instead of sun urlS-H-GAMELINKS2020-08-051-1/+1
| | | | [ci skip]
* Use https instead of httpKazuhiro NISHIYAMA2020-07-281-1/+1
|
* fix MJIT link error卜部昌平2020-07-131-1/+1
|
* inline Primitive.cexpr!卜部昌平2020-07-131-0/+12
| | | | | We can obtain the verbatim source code of Primitive.cexpr!. Why not paste that content into the JITed program.
* add UNREACHABLE_RETURN卜部昌平2020-06-291-0/+1
| | | | | | 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.
* fix_pow: do not goto into a branch卜部昌平2020-06-291-31/+26
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* int_pow: do not goto into a branch卜部昌平2020-06-291-7/+9
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* flo_to_s: do not goto into a branch卜部昌平2020-06-291-11/+14
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* Mark some Integer methods as inline (#3264)Takashi Kokubun2020-06-271-73/+0
|
* Make Integer#zero? a separated method and builtin (#3226)Takashi Kokubun2020-06-201-7/+17
| | | | | | | 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].
* Remove unused else if statements in int_even_p func (#3220)S.H2020-06-161-10/+6
| | | | | | | * remove else if & rb_funcall * fix int_even_p impl * fix rb_int_odd_p implementation
* Add static modifier for rb_int_ceil & rb_int_floor (#3217)S.H2020-06-161-4/+4
|
* numeric.c: optimize `float ** 2` case by fastpathYusuke Endoh2020-05-121-1/+5
| | | | | | It would be a relatively frequent case. It is still slower than `float * float` because `*` has a dedicated VM instruction (opt_mult), though.
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* Added more NORETURN declarationsNobuyoshi Nakada2020-05-111-0/+2
|
* numeric.c: Remove unreachable codeYusuke Endoh2020-04-091-4/+1
| | | | b cannot be <= 0 here. Found by Coverity Scan
* Suppress C4244 "possible loss of data" warningsNobuyoshi Nakada2020-04-081-1/+1
|
* Suppress -Wswitch warningsNobuyoshi Nakada2020-04-081-0/+2
|
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-4/+16
| | | Split ruby.h
* Removed non-RUBY_INTEGER_UNIFICATION codeNobuyoshi Nakada2020-03-211-6/+0
|
* Remove Float::ROUNDSJeremy Evans2020-03-091-20/+0
| | | | Fixes [Bug #16044]
* Check the encoding of `half:` optionNobuyoshi Nakada2020-01-271-0/+1
|
* decouple internal.h headers卜部昌平2019-12-261-4/+18
| | | | | | | | | | | | | | | | | | 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).
* add several __has_something macro卜部昌平2019-12-261-11/+11
| | | | | | | 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().
* make functions static卜部昌平2019-11-191-3/+4
| | | | | | | 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.