Project

General

Profile

Bug #10576 ยป doc_bigdecimal_p2.patch

patch 2 (apply after patch 1) - stomar (Marcus Stollsteimer), 12/06/2014 01:52 PM

View differences:

ext/bigdecimal/bigdecimal.c 2014-12-06 14:28:15.000000000 +0100
362 362
 * Method used to provide marshalling support.
363 363
 *
364 364
 *      inf = BigDecimal.new('Infinity')
365
 *      => #<BigDecimal:1e16fa8,'Infinity',9(9)>
365
 *        #=> #<BigDecimal:1e16fa8,'Infinity',9(9)>
366 366
 *      BigDecimal._load(inf._dump)
367
 *      => #<BigDecimal:1df8dc8,'Infinity',9(9)>
367
 *        #=> #<BigDecimal:1df8dc8,'Infinity',9(9)>
368 368
 *
369 369
 * See the Marshal module.
370 370
 */
......
613 613
    return pv;
614 614
}
615 615

  
616
/* Returns True if the value is Not a Number */
616
/* Returns True if the value is Not a Number. */
617 617
static VALUE
618 618
BigDecimal_IsNaN(VALUE self)
619 619
{
......
634 634
    return Qnil;
635 635
}
636 636

  
637
/* Returns True if the value is finite (not NaN or infinite) */
637
/* Returns True if the value is finite (not NaN or infinite). */
638 638
static VALUE
639 639
BigDecimal_IsFinite(VALUE self)
640 640
{
......
798 798
 * be coerced into a BigDecimal value.
799 799
 *
800 800
 * e.g.
801
 * a = BigDecimal.new("1.0")
802
 * b = a / 2.0  -> 0.5
801
 *   a = BigDecimal.new("1.0")
802
 *   b = a / 2.0 #=> 0.5
803 803
 *
804 804
 * Note that coercing a String to a BigDecimal is not supported by default;
805 805
 * it requires a special compile-time option when building Ruby.
......
857 857
  *   c = a + b
858 858
  *
859 859
  * digits:: If specified and less than the number of significant digits of the
860
  * result, the result is rounded to that number of digits, according to
861
  * BigDecimal.mode.
860
  *          result, the result is rounded to that number of digits, according
861
  *          to BigDecimal.mode.
862 862
  */
863 863
static VALUE
864 864
BigDecimal_add(VALUE self, VALUE r)
......
902 902
}
903 903

  
904 904
 /* call-seq:
905
  * value - digits   -> bigdecimal
905
  * a - b   -> bigdecimal
906 906
  *
907 907
  * Subtract the specified value.
908 908
  *
......
1086 1086
 *
1087 1087
 * Values may be coerced to perform the comparison:
1088 1088
 *
1089
 * BigDecimal.new('1.0') == 1.0  -> true
1089
 *   BigDecimal.new('1.0') == 1.0  -> true
1090 1090
 */
1091 1091
static VALUE
1092 1092
BigDecimal_eq(VALUE self, VALUE r)
......
1178 1178
  *   c = a * b
1179 1179
  *
1180 1180
  * digits:: If specified and less than the number of significant digits of the
1181
  * result, the result is rounded to that number of digits, according to
1182
  * BigDecimal.mode.
1181
  *          result, the result is rounded to that number of digits, according
1182
  *          to BigDecimal.mode.
1183 1183
  */
1184 1184
static VALUE
1185 1185
BigDecimal_mult(VALUE self, VALUE r)
......
1252 1252
  *   c = a.div(b,n)
1253 1253
  *
1254 1254
  * digits:: If specified and less than the number of significant digits of the
1255
  * result, the result is rounded to that number of digits, according to
1256
  * BigDecimal.mode.
1255
  *          result, the result is rounded to that number of digits, according
1256
  *          to BigDecimal.mode.
1257 1257
  *
1258 1258
  * If digits is 0, the result is the same as the / operator. If not, the
1259 1259
  * result is an integer BigDecimal, by analogy with Float#div.
......
1432 1432
    return Qnil;
1433 1433
}
1434 1434

  
1435
/* Returns the remainder from dividing by the value.
1435
/* call-seq:
1436
 * remainder(value)
1437
 *
1438
 * Returns the remainder from dividing by the value.
1436 1439
 *
1437 1440
 * x.remainder(y) means x-y*(x/y).truncate
1438 1441
 */
......
1446 1449
    return ToValue(rv);
1447 1450
}
1448 1451

  
1449
/* Divides by the specified value, and returns the quotient and modulus
1452
/* call-seq:
1453
 * divmod(value)
1454
 *
1455
 * Divides by the specified value, and returns the quotient and modulus
1450 1456
 * as BigDecimal numbers. The quotient is rounded towards negative infinity.
1451 1457
 *
1452 1458
 * For example:
1453 1459
 *
1454
 * require 'bigdecimal'
1460
 *   require 'bigdecimal'
1455 1461
 *
1456
 * a = BigDecimal.new("42")
1457
 * b = BigDecimal.new("9")
1462
 *   a = BigDecimal.new("42")
1463
 *   b = BigDecimal.new("9")
1458 1464
 *
1459
 * q,m = a.divmod(b)
1465
 *   q, m = a.divmod(b)
1460 1466
 *
1461
 * c = q * b + m
1467
 *   c = q * b + m
1462 1468
 *
1463
 * a == c  -> true
1469
 *   a == c  #=> true
1464 1470
 *
1465 1471
 * The quotient q is (a/b).floor, and the modulus is the amount that must be
1466 1472
 * added to q * b to get a.
......
1547 1553
    }
1548 1554
}
1549 1555

  
1550
/*
1556
/* call-seq:
1551 1557
 * sub(value, digits)  -> bigdecimal
1552 1558
 *
1553 1559
 * Subtract the specified value.
......
1556 1562
 *   c = a.sub(b,n)
1557 1563
 *
1558 1564
 * digits:: If specified and less than the number of significant digits of the
1559
 * result, the result is rounded to that number of digits, according to
1560
 * BigDecimal.mode.
1565
 *          result, the result is rounded to that number of digits, according
1566
 *          to BigDecimal.mode.
1561 1567
 *
1562 1568
 */
1563 1569
static VALUE
......
1597 1603

  
1598 1604
/* Returns the absolute value, as a BigDecimal.
1599 1605
 *
1600
 * BigDecimal('5').abs -> 5
1601
 *
1602
 * BigDecimal('-3').abs -> 3
1606
 *   BigDecimal('5').abs #=> 5
1607
 *   BigDecimal('-3').abs #=> 3
1603 1608
 */
1604 1609
static VALUE
1605 1610
BigDecimal_abs(VALUE self)
......
1894 1899
 *
1895 1900
 * Examples:
1896 1901
 *
1897
 *	BigDecimal.new('-123.45678901234567890').to_s('5F')
1898
 *	    #=> '-123.45678 90123 45678 9'
1902
 *   BigDecimal.new('-123.45678901234567890').to_s('5F')
1903
 *     #=> '-123.45678 90123 45678 9'
1899 1904
 *
1900
 *	BigDecimal.new('123.45678901234567890').to_s('+8F')
1901
 *	    #=> '+123.45678901 23456789'
1905
 *   BigDecimal.new('123.45678901234567890').to_s('+8F')
1906
 *     #=> '+123.45678901 23456789'
1902 1907
 *
1903
 *	BigDecimal.new('123.45678901234567890').to_s(' F')
1904
 *	    #=> ' 123.4567890123456789'
1908
 *   BigDecimal.new('123.45678901234567890').to_s(' F')
1909
 *     #=> ' 123.4567890123456789'
1905 1910
 */
1906 1911
static VALUE
1907 1912
BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
......
2041 2046
/* Returns debugging information about the value as a string of comma-separated
2042 2047
 * values in angle brackets with a leading #:
2043 2048
 *
2044
 * BigDecimal.new("1234.5678").inspect ->
2045
 * "#<BigDecimal:b7ea1130,'0.12345678E4',8(12)>"
2049
 *   BigDecimal.new("1234.5678").inspect
2050
 *     #=> "#<BigDecimal:b7ea1130,'0.12345678E4',8(12)>"
2046 2051
 *
2047 2052
 * The first part is the address, the second is the value as a string, and
2048 2053
 * the final part ss(mm) is the current number of significant digits and the
......
2196 2201
 *
2197 2202
 * Note that n must be an Integer.
2198 2203
 *
2199
 * Also available as the operator **
2204
 * Also available as the operator **.
2200 2205
 */
2201 2206
static VALUE
2202 2207
BigDecimal_power(int argc, VALUE*argv, VALUE self)
......
2428 2433
}
2429 2434

  
2430 2435
/* call-seq:
2431
 *   big_decimal ** exp  -> big_decimal
2436
 *   a ** n  -> bigdecimal
2437
 *
2438
 * Returns the value raised to the power of n.
2432 2439
 *
2433
 * It is a synonym of BigDecimal#power(exp).
2440
 * See BigDecimal#power.
2434 2441
 */
2435 2442
static VALUE
2436 2443
BigDecimal_power_op(VALUE self, VALUE exp)