@@ -5776,27 +5776,62 @@ int_floor(int argc, VALUE* argv, VALUE num)
5776
5776
}
5777
5777
5778
5778
/*
5779
+ * :markup: markdown
5780
+ *
5779
5781
* call-seq:
5780
5782
* ceil(ndigits = 0) -> integer
5781
5783
*
5782
- * Returns the smallest number greater than or equal to +self+ with
5783
- * a precision of +ndigits+ decimal digits.
5784
+ * Returns an integer that is a "ceiling" value for `self`,
5785
+ * as specified by the given `ndigits`,
5786
+ * which must be an
5787
+ * [integer-convertible object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
5784
5788
*
5785
- * When the precision is negative, the returned value is an integer
5786
- * with at least <code>ndigits.abs</code> trailing zeros:
5789
+ * - When `self` is zero, returns zero (regardless of the value of `ndigits`):
5787
5790
*
5788
- * 555.ceil(-1) # => 560
5789
- * 555 .ceil(- 2) # => 600
5790
- * -555 .ceil(-2) # => -500
5791
- * 555.ceil(-3) # => 1000
5791
+ * ```
5792
+ * 0 .ceil(2) # => 0
5793
+ * 0 .ceil(-2) # => 0
5794
+ * ```
5792
5795
*
5793
- * Returns + self+ when + ndigits+ is zero or positive.
5796
+ * - When ` self` is non-zero and ` ndigits` is non-negative, returns `self`:
5794
5797
*
5795
- * 555.ceil # => 555
5796
- * 555.ceil(50) # => 555
5798
+ * ```
5799
+ * 555.ceil # => 555
5800
+ * 555.ceil(50) # => 555
5801
+ * ```
5797
5802
*
5798
- * Related: Integer#floor.
5803
+ * - When `self` is non-zero and `ndigits` is negative,
5804
+ * returns a value based on a computed granularity:
5805
+ *
5806
+ * - The granularity is <tt>ndigits.abs * 10</tt>.
5807
+ * - The returned value is the smallest multiple of the granularity
5808
+ * that is greater than or equal to `self`.
5809
+ *
5810
+ * Examples with positive `self`:
5799
5811
*
5812
+ * | ndigits | Granularity | 1234.ceil(ndigits) |
5813
+ * |--------:|------------:|-------------------:|
5814
+ * | -1 | 10 | 1240 |
5815
+ * | -2 | 100 | 1300 |
5816
+ * | -3 | 1000 | 2000 |
5817
+ * | -4 | 10000 | 10000 |
5818
+ * | -5 | 100000 | 100000 |
5819
+ *
5820
+ * <br>
5821
+ *
5822
+ * Examples with negative `self`:
5823
+ *
5824
+ * | ndigits | Granularity | -1234.ceil(ndigits) |
5825
+ * |--------:|------------:|--------------------:|
5826
+ * | -1 | 10 | -1230 |
5827
+ * | -2 | 100 | -1200 |
5828
+ * | -3 | 1000 | -1000 |
5829
+ * | -4 | 10000 | 0 |
5830
+ * | -5 | 100000 | 0 |
5831
+ *
5832
+ * <br>
5833
+ *
5834
+ * Related: Integer#floor.
5800
5835
*/
5801
5836
5802
5837
static VALUE
0 commit comments