@@ -1121,12 +1121,14 @@ BigDecimal_coerce(VALUE self, VALUE other)
11211121}
11221122
11231123/*
1124- * call-seq:
1125- * +big_decimal -> big_decimal
1124+ * call-seq:
1125+ * +big_decimal -> big_decimal
1126+ *
1127+ * Returns +self+:
11261128 *
1127- * Return self.
1129+ * +BigDecimal(5) # => 0.5e1
1130+ * +BigDecimal(-5) # => -0.5e1
11281131 *
1129- * +BigDecimal('5') #=> 0.5e1
11301132 */
11311133
11321134static VALUE
@@ -1136,22 +1138,16 @@ BigDecimal_uplus(VALUE self)
11361138}
11371139
11381140 /*
1139- * Document-method: BigDecimal#add
1140- * Document-method: BigDecimal#+
1141+ * call-seq:
1142+ * self + value -> new_bigdecimal
11411143 *
1142- * call-seq:
1143- * add(value, digits)
1144+ * Returns the sum of +self+ and +value+:
11441145 *
1145- * Add the specified value.
1146- *
1147- * e.g.
1148- * c = a.add(b,n)
1149- * c = a + b
1146+ * b = BigDecimal('111111.111') # => 0.111111111e6
1147+ * b + 1 # => 0.111112111e6
11501148 *
1151- * digits:: If specified and less than the number of significant digits of the
1152- * result, the result is rounded to that number of digits, according
1153- * to BigDecimal.mode.
11541149 */
1150+
11551151static VALUE
11561152BigDecimal_add (VALUE self , VALUE r )
11571153{
@@ -1882,6 +1878,31 @@ BigDecimal_div3(int argc, VALUE *argv, VALUE self)
18821878 return BigDecimal_div2 (self , b , n );
18831879}
18841880
1881+ /*
1882+ * call-seq:
1883+ * add(value, ndigits)
1884+ *
1885+ * Returns the sum of +self+ and +value+
1886+ * with a precision of +ndigits+ decimal digits.
1887+ *
1888+ * When +ndigits+ is less than the number of significant digits
1889+ * in the sum, the sum is rounded to that number of digits,
1890+ * according to the current rounding mode; see BigDecimal.mode.
1891+ *
1892+ * Examples:
1893+ *
1894+ * BigDecimal('111111.111').add(1, 0) # => 0.111112111e6
1895+ * BigDecimal('111111.111').add(1, 2) # => 0.11e6
1896+ * BigDecimal('111111.111').add(1, 3) # => 0.111e6
1897+ * BigDecimal('111111.111').add(1, 4) # => 0.1111e6
1898+ * BigDecimal('111111.111').add(1, 5) # => 0.11111e6
1899+ * BigDecimal('111111.111').add(1, 6) # => 0.111112e6
1900+ * BigDecimal('111111.111').add(1, 7) # => 0.1111121e6
1901+ * BigDecimal('111111.111').add(1, 8) # => 0.11111211e6
1902+ * BigDecimal('111111.111').add(1, 9) # => 0.111112111e6
1903+ *
1904+ */
1905+
18851906static VALUE
18861907BigDecimal_add2 (VALUE self , VALUE b , VALUE n )
18871908{
0 commit comments