8000 [DOC] Doc for Integer#ceil by BurdetteLamar · Pull Request #11075 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

[DOC] Doc for Integer#ceil #11075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Doc for Integer#ceil
  • Loading branch information
BurdetteLamar committed Jun 29, 2024
commit 59dfd49ffed21fcec89e74a23686db1c0eb81514
59 changes: 47 additions & 12 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -5776,27 +5776,62 @@ int_floor(int argc, VALUE* argv, VALUE num)
}

/*
* :markup: markdown
*
* call-seq:
* ceil(ndigits = 0) -> integer
*
* Returns the smallest number greater than or equal to +self+ with
* a precision of +ndigits+ decimal digits.
* Returns an integer that is a "ceiling" value for `self`,
* as specified by the given `ndigits`,
* which must be an
* [integer-convertible object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
*
* When the precision is negative, the returned value is an integer
* with at least <code>ndigits.abs</code> trailing zeros:
* - When `self` is zero, returns zero (regardless of the value of `ndigits`):
*
* 555.ceil(-1) # => 560
* 555.ceil(-2) # => 600
* -555.ceil(-2) # => -500
* 555.ceil(-3) # => 1000
* ```
* 0.ceil(2) # => 0
* 0.ceil(-2) # => 0
* ```
*
* Returns +self+ when +ndigits+ is zero or positive.
* - When `self` is non-zero and `ndigits` is non-negative, returns `self`:
*
* 555.ceil # => 555
* 555.ceil(50) # => 555
* ```
* 555.ceil # => 555
* 555.ceil(50) # => 555
* ```
*
* Related: Integer#floor.
* - When `self` is non-zero and `ndigits` is negative,
* returns a value based on a computed granularity:
*
* - The granularity is <tt>ndigits.abs * 10</tt>.
* - The returned value is the smallest multiple of the granularity
* that is greater than or equal to `self`.
*
* Examples with positive `self`:
*
* | ndigits | Granularity | 1234.ceil(ndigits) |
* |--------:|------------:|-------------------:|
* | -1 | 10 | 1240 |
* | -2 | 100 | 1300 |
* | -3 | 1000 | 2000 |
* | -4 | 10000 | 10000 |
* | -5 | 100000 | 100000 |
*
* <br>
*
* Examples with negative `self`:
*
* | ndigits | Granularity | -1234.ceil(ndigits) |
* |--------:|------------:|--------------------:|
* | -1 | 10 | -1230 |
* | -2 | 100 | -1200 |
* | -3 | 1000 | -1000 |
* | -4 | 10000 | 0 |
* | -5 | 100000 | 0 |
*
* <br>
*
* Related: Integer#floor.
*/

static VALUE
Expand Down
0