diff options
author | Burdette Lamar <[email protected]> | 2021-10-12 08:06:05 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2021-10-12 08:06:05 -0500 |
commit | bb66729b5ffb0e59825503d5d5b703d60c8a3f85 (patch) | |
tree | a893ca267f79f8cefaabae6d443782115a2f6928 /numeric.c | |
parent | 58ae1efb49e2ba10960a62b4f4e1c01811b71e59 (diff) |
Enhanced RDoc for Numeric#% (#4954)
Notes
Notes:
Merged-By: BurdetteLamar <[email protected]>
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -620,13 +620,38 @@ num_div(VALUE x, VALUE y) /* * call-seq: - * num.modulo(numeric) -> real + * self % other -> real_numeric * - * <code>x.modulo(y)</code> means <code>x-y*(x/y).floor</code>. + * Returns +self+ modulo +other+ as a real number. * - * Equivalent to <code>num.divmod(numeric)[1]</code>. + * Of the Core and Standard Library classes, + * only Rational uses this implementation. + * + * For \Rational +r+ and real number +n+, these expressions are equivalent: + * + * c % n + * c-n*(c/n).floor + * c.divmod(n)[1] * * See Numeric#divmod. + * + * Examples: + * + * r = Rational(1, 2) # => (1/2) + * r2 = Rational(2, 3) # => (2/3) + * r % r2 # => (1/2) + * r % 2 # => (1/2) + * r % 2.0 # => 0.5 + * + * r = Rational(301,100) # => (301/100) + * r2 = Rational(7,5) # => (7/5) + * r % r2 # => (21/100) + * r % -r2 # => (-119/100) + * (-r) % r2 # => (119/100) + * (-r) %-r2 # => (-21/100) + * + * Numeric#modulo is an alias for Numeric#%. + * */ static VALUE @@ -3718,7 +3743,6 @@ rb_int_idiv(VALUE x, VALUE y) * * See Numeric#divmod for more information. */ - static VALUE fix_mod(VALUE x, VALUE y) { |