summaryrefslogtreecommitdiff
path: root/numeric.c
AgeCommit message (Collapse)Author
5 days[DOC] Harmonize #> methodsBurdette Lamar
8 days[DOC] Harmonize #== methods (#15805)Burdette Lamar
9 days[DOC] Harmonize #>= methodsBurdetteLamar
2025-12-19[DOC] Harmonize several <=> methodsBurdetteLamar
2025-12-19[DOC] Harmonize <= methodsBurdetteLamar
2025-12-18[DOC] Harmonize lt methodsBurdette Lamar
2025-12-16[DOC] Harmonize rb_div methodsBurdetteLamar
2025-12-15[DOC] Harmonize #-@ methodsBurdetteLamar
2025-12-15[DOC] Harmonize #- methodsBurdetteLamar
2025-12-15[DOC] Harmonize #** methodsBurdetteLamar
2025-12-14[DOC] Fix backticks in Numeric#ceilPeter Zhu
2025-12-14[DOC] Fix backticks in Numeric#floorPeter Zhu
2025-12-08Fix strict aliasing warning in rb_int128_to_numericPeter Zhu
If we don't have uint128, then rb_int128_to_numeric emits a strict aliasing warning: numeric.c:3641:39: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 3641 | return rb_uint128_to_numeric(*(rb_uint128_t*)&n); | ^~~~~~~~~~~~~~~~~
2025-12-06Add support for `u128`, `U128`, `s128` and `S128` integers to `IO::Buffer`. ↵Samuel Williams
(#15399)
2025-12-02[DOC] About Float Imprecision (#15293)Burdette Lamar
2025-12-02[DOC] Harmonize #+ methodsBurdette Lamar
2025-11-28[DOC] Avoid term 'derived'; use 'subclass'BurdetteLamar
2025-11-21[DOC] Tweaks for Integer#**BurdetteLamar
2025-11-21[DOC] Harmonize #* methodsBurdetteLamar
2025-11-20[DOC] Harmonize mod methodsBurdetteLamar
2025-11-19Win32: Drop support for older than MSVC 8.0/_MSC_VER 1400Nobuyoshi Nakada
Visual C++ 2005 (8.0): - _MSC_VER: 1400 - MSVCRT_VERSION: 80
2025-11-12[Bug #21680] Fix (base**power_of_two).digits(base) bug (#15144)tomoya ishida
Fix wrong condition in base multiplying loop.
2025-09-16[DOC] Markup code in `Float::MIN` documentNobuyoshi Nakada
2025-07-29Improve performance of bignum[beg, len] (#14007)tomoya ishida
Implement rb_big_aref2. Taking a small slice from large bignum was slow in rb_int_aref2.
2025-04-07Fix `Integer.sqrt` to never exceed actual valueYusuke Endoh
`Integer.sqrt` uses `sqrt(3)` from libm for small values. This method must return a value less than or equal to the actual integer square root, but libm's sqrt does not always guarantee that. This change corrects that by decrementing the result if necessary. Fixes [Bug #21217] Notes: Merged: https://github.com/ruby/ruby/pull/13076
2025-02-27[DOC] Fix indentationNobuyoshi Nakada
Not to make preceding paragraphs a code block. Notes: Merged: https://github.com/ruby/ruby/pull/12820
2025-01-02[DOC] Exclude 'Class' and 'Module' from RDoc's autolinkingNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12496
2025-01-02[DOC] Exclude 'Method' from RDoc's autolinkingNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12496
2024-12-17[DOC] Fix example in Numeric#to_intBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12372
2024-12-02Correct order of listed methodsBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/12229
2024-10-22Rewrite Numeric#dup and Numeric#+@ in Ruby (#11933)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2024-10-07[DOC] Move each `Float#to_s` example item by itemNobuyoshi Nakada
Like as +half+ option in Float#round. If the body of the preceding list items and the following code block are indented at the same position, the code block is parsed as a list continuation. [Fixes GH-11683]
2024-09-10[DOC] Fix linksBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/11527
2024-07-30Fix ceil when ndigits is largePeter Zhu
[Bug #20654] This commit fixes Integer#ceil and Float#ceil when the number is negative and ndigits is large such that 10**ndigits is a bignum. Previously, it would return 0 in such cases. However, this would cause unexpected behaviour such as: puts 1.ceil(-5) # => 100000 puts 1.ceil(-10) # => 10000000000 puts 1.ceil(-20) # => 0 This commit changes the last result so that it will return 100000000000000000000. Notes: Merged: https://github.com/ruby/ruby/pull/11257
2024-07-30Fix floor when ndigits is largePeter Zhu
[Bug #20654] This commit fixes Integer#floor and Float#floor when the number is negative and ndigits is large such that 10**ndigits is a bignum. Previously, it would return 0 in such cases. However, this would cause unexpected behaviour such as: puts -1.floor(-5) # => -100000 puts -1.floor(-10) # => -10000000000 puts -1.floor(-20) # => 0 This commit changes the last result so that it will return -100000000000000000000. Notes: Merged: https://github.com/ruby/ruby/pull/11257
2024-07-29Revert moving things to RubyAaron Patterson
This is slowing down benchmarks on x86, so lets revert it for now. Notes: Merged: https://github.com/ruby/ruby/pull/11275
2024-07-26Doc for some #ceil and #floorBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/11245
2024-07-26Doc for some #ceil and #floorBurdetteLamar
Notes: Merged: https://github.com/ruby/ruby/pull/11245
2024-07-09[DOC] Doc for Float#ceil (#11125)Burdette Lamar
2024-07-09[DOC] Use backticks instead of HTML tagsPeter Zhu
2024-07-09[DOC] Fix granularity calculationPeter Zhu
The granularity is calculated as `10 ** ndigits.abs` rather than `ndigits.abs * 10`. For example, if `ndigits` is `-2`, it should be `10 ** 2 == 100` rather than `2 * 10 == 20`.
2024-07-08Doc fixesBurdetteLamar
2024-07-03[DOC] Doc for Integer#floor (#11077)Burdette Lamar
2024-07-03move Integer#downto to RubyAaron Patterson
Speeds up ChunkyPNG. The interpreter is about 70% faster: ``` before: ruby 3.4.0dev (2024-07-03T15:16:17Z master 786cf9db48) [arm64-darwin23] after: ruby 3.4.0dev (2024-07-03T15:32:25Z ruby-downto 0b8b744ce2) [arm64-darwin23] ---------- ----------- ---------- ---------- ---------- ------------- ------------ bench before (ms) stddev (%) after (ms) stddev (%) after 1st itr before/after chunky-png 892.2 0.1 526.3 1.0 1.65 1.70 ---------- ----------- ---------- ---------- ---------- ------------- ------------ Legend: - after 1st itr: ratio of before/after time for the first benchmarking iteration. - before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup. ``` YJIT is 2.5x faster: ``` before: ruby 3.4.0dev (2024-07-03T15:16:17Z master 786cf9db48) +YJIT [arm64-darwin23] after: ruby 3.4.0dev (2024-07-03T15:32:25Z ruby-downto 0b8b744ce2) +YJIT [arm64-darwin23] ---------- ----------- ---------- ---------- ---------- ------------- ------------ bench before (ms) stddev (%) after (ms) stddev (%) after 1st itr before/after chunky-png 709.4 0.1 278.8 0.3 2.35 2.54 ---------- ----------- ---------- ---------- ---------- ------------- ------------ Legend: - after 1st itr: ratio of before/after time for the first benchmarking iteration. - before/after: ratio of before/after time. Higher is better for after. Above 1 represents a speedup. ```
2024-06-29Doc for Integer#ceilBurdetteLamar
2024-04-26[DOC] Enhance `Numeric#nonzero?` docArtur
Add `zero?` as a related method
2024-04-08Reducing the number of divisions in `rb_fix_digits`Reznov
2024-03-27Register rb_fix_to_s_static as global right after creatingPeter Zhu
If a GC runs right during creating a rb_fix_to_s_static, it may cause the previous ones to become swept by the GC because they have not been registered by rb_vm_register_global_object.
2024-03-18Faster Integer.sqrt for large bignumtompng
Integer.sqrt uses Newton's method. This pull request reduces the precision which was unnecessarily high in each calculation step.
2024-03-06Refactor VM root modulesJean Boussier
This `st_table` is used to both mark and pin classes defined from the C API. But `vm->mark_object_ary` already does both much more efficiently. Currently a Ruby process starts with 252 rooted classes, which uses `7224B` in an `st_table` or `2016B` in an `RArray`. So a baseline of 5kB saved, but since `mark_object_ary` is preallocated with `1024` slots but only use `405` of them, it's a net `7kB` save. `vm->mark_object_ary` is also being refactored. Prior to this changes, `mark_object_ary` was a regular `RArray`, but since this allows for references to be moved, it was marked a second time from `rb_vm_mark()` to pin these objects. This has the detrimental effect of marking these references on every minors even though it's a mostly append only list. But using a custom TypedData we can save from having to mark all the references on minor GC runs. Addtionally, immediate values are now ignored and not appended to `vm->mark_object_ary` as it's just wasted space.