Project

General

Profile

Bug #13233 ยป rdoc_rational.patch

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

View differences:

rational.c
1252 1252
 *
1253 1253
 *  Returns the absolute value of +rat+.
1254 1254
 *
1255
 *  (1/2r).abs    #=> 1/2r
1256
 *  (-1/2r).abs   #=> 1/2r
1255
 *     (1/2r).abs    #=> 1/2r
1256
 *     (-1/2r).abs   #=> 1/2r
1257 1257
 *
1258 1258
 *  Rational#magnitude is an alias of Rational#abs.
1259 1259
 */
......
1289 1289
 *
1290 1290
 * Returns the truncated value as an integer.
1291 1291
 *
1292
 * Equivalent to
1293
 *    rat.truncate.
1292
 * Equivalent to Rational#truncate.
1294 1293
 *
1295 1294
 *    Rational(2, 3).to_i   #=> 0
1296 1295
 *    Rational(3).to_i      #=> 3
......
1430 1429
 *    Rational(2, 3).floor   #=> 0
1431 1430
 *    Rational(-3, 2).floor  #=> -1
1432 1431
 *
1433
 *           decimal      -  1  2  3 . 4  5  6
1434
 *                          ^  ^  ^  ^   ^  ^
1435
 *          precision      -3 -2 -1  0  +1 +2
1432
 *      #    decimal      -  1  2  3 . 4  5  6
1433
 *      #                   ^  ^  ^  ^   ^  ^
1434
 *      #   precision      -3 -2 -1  0  +1 +2
1436 1435
 *
1437 1436
 *    '%f' % Rational('-123.456').floor(+1)  #=> "-123.500000"
1438 1437
 *    '%f' % Rational('-123.456').floor(-1)  #=> "-130.000000"
......
1454 1453
 *    Rational(2, 3).ceil   #=> 1
1455 1454
 *    Rational(-3, 2).ceil  #=> -1
1456 1455
 *
1457
 *           decimal      -  1  2  3 . 4  5  6
1458
 *                          ^  ^  ^  ^   ^  ^
1459
 *          precision      -3 -2 -1  0  +1 +2
1456
 *      #    decimal      -  1  2  3 . 4  5  6
1457
 *      #                   ^  ^  ^  ^   ^  ^
1458
 *      #   precision      -3 -2 -1  0  +1 +2
1460 1459
 *
1461 1460
 *    '%f' % Rational('-123.456').ceil(+1)  #=> "-123.400000"
1462 1461
 *    '%f' % Rational('-123.456').ceil(-1)  #=> "-120.000000"
......
1478 1477
 *    Rational(2, 3).truncate   #=> 0
1479 1478
 *    Rational(-3, 2).truncate  #=> -1
1480 1479
 *
1481
 *           decimal      -  1  2  3 . 4  5  6
1482
 *                          ^  ^  ^  ^   ^  ^
1483
 *          precision      -3 -2 -1  0  +1 +2
1480
 *      #    decimal      -  1  2  3 . 4  5  6
1481
 *      #                   ^  ^  ^  ^   ^  ^
1482
 *      #   precision      -3 -2 -1  0  +1 +2
1484 1483
 *
1485 1484
 *    '%f' % Rational('-123.456').truncate(+1)  #=>  "-123.400000"
1486 1485
 *    '%f' % Rational('-123.456').truncate(-1)  #=>  "-120.000000"
......
1503 1502
 *    Rational(2, 3).round   #=> 1
1504 1503
 *    Rational(-3, 2).round  #=> -2
1505 1504
 *
1506
 *           decimal      -  1  2  3 . 4  5  6
1507
 *                          ^  ^  ^  ^   ^  ^
1508
 *          precision      -3 -2 -1  0  +1 +2
1505
 *      #    decimal      -  1  2  3 . 4  5  6
1506
 *      #                   ^  ^  ^  ^   ^  ^
1507
 *      #   precision      -3 -2 -1  0  +1 +2
1509 1508
 *
1510 1509
 *    '%f' % Rational('-123.456').round(+1)  #=> "-123.500000"
1511 1510
 *    '%f' % Rational('-123.456').round(-1)  #=> "-120.000000"