Project

General

Profile

Bug #13233 ยป rdoc_rational.patch

stomar (Marcus Stollsteimer), 02/20/2017 05:08 AM

View differences:

rational.c
*
* Returns the absolute value of +rat+.
*
* (1/2r).abs #=> 1/2r
* (-1/2r).abs #=> 1/2r
* (1/2r).abs #=> 1/2r
* (-1/2r).abs #=> 1/2r
*
* Rational#magnitude is an alias of Rational#abs.
*/
......
*
* Returns the truncated value as an integer.
*
* Equivalent to
* rat.truncate.
* Equivalent to Rational#truncate.
*
* Rational(2, 3).to_i #=> 0
* Rational(3).to_i #=> 3
......
* Rational(2, 3).floor #=> 0
* Rational(-3, 2).floor #=> -1
*
* decimal - 1 2 3 . 4 5 6
* ^ ^ ^ ^ ^ ^
* precision -3 -2 -1 0 +1 +2
* # decimal - 1 2 3 . 4 5 6
* # ^ ^ ^ ^ ^ ^
* # precision -3 -2 -1 0 +1 +2
*
* '%f' % Rational('-123.456').floor(+1) #=> "-123.500000"
* '%f' % Rational('-123.456').floor(-1) #=> "-130.000000"
......
* Rational(2, 3).ceil #=> 1
* Rational(-3, 2).ceil #=> -1
*
* decimal - 1 2 3 . 4 5 6
* ^ ^ ^ ^ ^ ^
* precision -3 -2 -1 0 +1 +2
* # decimal - 1 2 3 . 4 5 6
* # ^ ^ ^ ^ ^ ^
* # precision -3 -2 -1 0 +1 +2
*
* '%f' % Rational('-123.456').ceil(+1) #=> "-123.400000"
* '%f' % Rational('-123.456').ceil(-1) #=> "-120.000000"
......
* Rational(2, 3).truncate #=> 0
* Rational(-3, 2).truncate #=> -1
*
* decimal - 1 2 3 . 4 5 6
* ^ ^ ^ ^ ^ ^
* precision -3 -2 -1 0 +1 +2
* # decimal - 1 2 3 . 4 5 6
* # ^ ^ ^ ^ ^ ^
* # precision -3 -2 -1 0 +1 +2
*
* '%f' % Rational('-123.456').truncate(+1) #=> "-123.400000"
* '%f' % Rational('-123.456').truncate(-1) #=> "-120.000000"
......
* Rational(2, 3).round #=> 1
* Rational(-3, 2).round #=> -2
*
* decimal - 1 2 3 . 4 5 6
* ^ ^ ^ ^ ^ ^
* precision -3 -2 -1 0 +1 +2
* # decimal - 1 2 3 . 4 5 6
* # ^ ^ ^ ^ ^ ^
* # precision -3 -2 -1 0 +1 +2
*
* '%f' % Rational('-123.456').round(+1) #=> "-123.500000"
* '%f' % Rational('-123.456').round(-1) #=> "-120.000000"
    (1-1/1)