parent
cad09f7098
commit
20a85ab611
Notes:
git
2023-01-22 09:53:28 +00:00
Merged-By: mrkn <mrkn@ruby-lang.org>
@ -278,7 +278,7 @@ class Integer
|
|||||||
#
|
#
|
||||||
# 3.ceildiv(1.2) # => 3
|
# 3.ceildiv(1.2) # => 3
|
||||||
def ceildiv(other)
|
def ceildiv(other)
|
||||||
-div(-other)
|
-div(0 - other)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -725,5 +725,9 @@ class TestInteger < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal(10, (10**100-11).ceildiv(10**99-1))
|
assert_equal(10, (10**100-11).ceildiv(10**99-1))
|
||||||
assert_equal(11, (10**100-9).ceildiv(10**99-1))
|
assert_equal(11, (10**100-9).ceildiv(10**99-1))
|
||||||
|
|
||||||
|
o = Object.new
|
||||||
|
def o.coerce(other); [other, 10]; end
|
||||||
|
assert_equal(124, 1234.ceildiv(o))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user