Skip to content

Commit 7d87b62

Browse files
Implement Integer#ceildiv.
Co-authored-by: Simon LeVasseur <simon.levasseur@shopify.com>
1 parent 2e9286e commit 7d87b62

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Compatibility:
3232
* Implement the `Data` class from Ruby 3.2 (#3039, @moste00, @eregon).
3333
* Make `Coverage.start` and `Coverage.result` accept parameters (#3149, @mtortonesi, @andrykonchin).
3434
* Implement `rb_check_funcall()` (@eregon).
35+
* Add `Integer#ceildiv` method (#3039, @simonlevasseur, @nirvdrum).
3536

3637
Performance:
3738

spec/tags/core/integer/ceildiv_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/ruby/truffleruby/core/integer.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ def ceil(precision = 0)
8888
((self / x) + 1) * x
8989
end
9090

91+
def ceildiv(other)
92+
-div(-other)
93+
end
94+
9195
def coerce(other)
9296
if Primitive.is_a?(other, Integer)
9397
return [other, self]

0 commit comments

Comments
 (0)