diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-28 02:15:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-28 02:15:51 +0000 |
commit | 83c2a9e9cc4785d3dd5cd2fefe87482f59de5cd7 (patch) | |
tree | 4ba06e9b6459f7472abc28cfde107a02acfa198f | |
parent | 6b18457d1505f0a432b3d9c1dbd20a4687b46978 (diff) | |
download | ruby-83c2a9e9cc4785d3dd5cd2fefe87482f59de5cd7.tar.gz |
numeric.c: improves Float#round rdoc [ci skip]
* numeric.c (flo_round): [DOC] improves Float#round documentation
to better highlight the half keyword. [Fix GH-1541]
Author: Evan Brodie <brodie.evan@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | doc/contributors.rdoc | 3 | ||||
-rw-r--r-- | numeric.c | 11 |
2 files changed, 12 insertions, 2 deletions
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 @@ -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 <code>half:</code> optional keyword is given, just-half number + * If the <code>half:</code> optional keyword is given, just-half number * will be rounded according to that value. * Supported values for this keyword are follows. * * * <code>:up</code> or +nil+: the result will be rounded away from zero * * <code>:even</code>: the result will be rounded to nearest even number * * <code>:down</code>: 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 |