Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

BigDecimal#ceil

ceil(p1 = v1)

ceil(n)

Return the smallest integer greater than or equal to the value, as a BigDecimal.

Example
BigDecimal('3.14159').ceil #=> 4
BigDecimal('-9.1').ceil #=> -9

If n is specified and positive, the fractional part of the result has no more than that many digits.

If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result.

Example
BigDecimal('3.14159').ceil(3) #=> 3.142
BigDecimal('13345.234').ceil(-2) #=> 13400.0
See also #as_json #clone #add #coerce also in 3.2 · 3.1 · 3.0