diff --git a/doc/contributors.rdoc b/doc/contributors.rdoc index ced4eb1cd0..75ecd2d956 100644 --- a/doc/contributors.rdoc +++ b/doc/contributors.rdoc @@ -57,6 +57,9 @@ Oliver M. Bolzer Alexey Borzenkov * a patch for mkmf.rb +Evan Brodie +* a patch for documentation of Float#round + Richard Brown * a patch for configure.in diff --git a/numeric.c b/numeric.c index 3d2b501ab2..4b0fcf01e5 100644 --- a/numeric.c +++ b/numeric.c @@ -2215,7 +2215,7 @@ rb_int_truncate(VALUE num, int ndigits) /* * call-seq: - * float.round([ndigits]) -> integer or float + * float.round([ndigits] [, half: symbol]) -> integer or float * * Rounds +float+ to a given precision in decimal digits (default 0 digits). * @@ -2242,13 +2242,20 @@ rb_int_truncate(VALUE num, int ndigits) * 34567.89.round(2) #=> 34567.89 * 34567.89.round(3) #=> 34567.89 * - * If half: optional keyword is given, just-half number + * If the half: optional keyword is given, just-half number * will be rounded according to that value. * Supported values for this keyword are follows. * * * :up or +nil+: the result will be rounded away from zero * * :even: the result will be rounded to nearest even number * * :down: the result will be rounded close to zero + * + * 2.5.round(half: :up) #=> 3 + * 2.5.round(half: :even) #=> 2 + * 2.5.round(half: :down) #=> 2 + * 3.5.round(half: :up) #=> 4 + * 3.5.round(half: :even) #=> 4 + * 3.5.round(half: :down) #=> 3 */ static VALUE