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
* Method used to provide marshalling support.
*
* inf = BigDecimal.new('Infinity')
* => #<BigDecimal:1e16fa8,'Infinity',9(9)>
* #=> #<BigDecimal:1e16fa8,'Infinity',9(9)>
* BigDecimal._load(inf._dump)
* => #<BigDecimal:1df8dc8,'Infinity',9(9)>
* #=> #<BigDecimal:1df8dc8,'Infinity',9(9)>
*
* See the Marshal module.
*/
......
return pv;
}
/* Returns True if the value is Not a Number */
/* Returns True if the value is Not a Number. */
static VALUE
BigDecimal_IsNaN(VALUE self)
{
......
return Qnil;
}
/* Returns True if the value is finite (not NaN or infinite) */
/* Returns True if the value is finite (not NaN or infinite). */
static VALUE
BigDecimal_IsFinite(VALUE self)
{
......
* be coerced into a BigDecimal value.
*
* e.g.
* a = BigDecimal.new("1.0")
* b = a / 2.0 -> 0.5
* a = BigDecimal.new("1.0")
* b = a / 2.0 #=> 0.5
*
* Note that coercing a String to a BigDecimal is not supported by default;
* it requires a special compile-time option when building Ruby.
......
* c = a + b
*
* digits:: If specified and less than the number of significant digits of the
* result, the result is rounded to that number of digits, according to
* BigDecimal.mode.
* result, the result is rounded to that number of digits, according
* to BigDecimal.mode.
*/
static VALUE
BigDecimal_add(VALUE self, VALUE r)
......
}
/* call-seq:
* value - digits -> bigdecimal
* a - b -> bigdecimal
*
* Subtract the specified value.
*
......
*
* Values may be coerced to perform the comparison:
*
* BigDecimal.new('1.0') == 1.0 -> true
* BigDecimal.new('1.0') == 1.0 -> true
*/
static VALUE
BigDecimal_eq(VALUE self, VALUE r)
......
* c = a * b
*
* digits:: If specified and less than the number of significant digits of the
* result, the result is rounded to that number of digits, according to
* BigDecimal.mode.
* result, the result is rounded to that number of digits, according
* to BigDecimal.mode.
*/
static VALUE
BigDecimal_mult(VALUE self, VALUE r)
......
* c = a.div(b,n)
*
* digits:: If specified and less than the number of significant digits of the
* result, the result is rounded to that number of digits, according to
* BigDecimal.mode.
* result, the result is rounded to that number of digits, according
* to BigDecimal.mode.
*
* If digits is 0, the result is the same as the / operator. If not, the
* result is an integer BigDecimal, by analogy with Float#div.
......
return Qnil;
}
/* Returns the remainder from dividing by the value.
/* call-seq:
* remainder(value)
*
* Returns the remainder from dividing by the value.
*
* x.remainder(y) means x-y*(x/y).truncate
*/
......
return ToValue(rv);
}
/* Divides by the specified value, and returns the quotient and modulus
/* call-seq:
* divmod(value)
*
* Divides by the specified value, and returns the quotient and modulus
* as BigDecimal numbers. The quotient is rounded towards negative infinity.
*
* For example:
*
* require 'bigdecimal'
* require 'bigdecimal'
*
* a = BigDecimal.new("42")
* b = BigDecimal.new("9")
* a = BigDecimal.new("42")
* b = BigDecimal.new("9")
*
* q,m = a.divmod(b)
* q, m = a.divmod(b)
*
* c = q * b + m
* c = q * b + m
*
* a == c -> true
* a == c #=> true
*
* The quotient q is (a/b).floor, and the modulus is the amount that must be
* added to q * b to get a.
......
}
}
/*
/* call-seq:
* sub(value, digits) -> bigdecimal
*
* Subtract the specified value.
......
* c = a.sub(b,n)
*
* digits:: If specified and less than the number of significant digits of the
* result, the result is rounded to that number of digits, according to
* BigDecimal.mode.
* result, the result is rounded to that number of digits, according
* to BigDecimal.mode.
*
*/
static VALUE
......
/* Returns the absolute value, as a BigDecimal.
*
* BigDecimal('5').abs -> 5
*
* BigDecimal('-3').abs -> 3
* BigDecimal('5').abs #=> 5
* BigDecimal('-3').abs #=> 3
*/
static VALUE
BigDecimal_abs(VALUE self)
......
*
* Examples:
*
* BigDecimal.new('-123.45678901234567890').to_s('5F')
* #=> '-123.45678 90123 45678 9'
* BigDecimal.new('-123.45678901234567890').to_s('5F')
* #=> '-123.45678 90123 45678 9'
*
* BigDecimal.new('123.45678901234567890').to_s('+8F')
* #=> '+123.45678901 23456789'
* BigDecimal.new('123.45678901234567890').to_s('+8F')
* #=> '+123.45678901 23456789'
*
* BigDecimal.new('123.45678901234567890').to_s(' F')
* #=> ' 123.4567890123456789'
* BigDecimal.new('123.45678901234567890').to_s(' F')
* #=> ' 123.4567890123456789'
*/
static VALUE
BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
......
/* Returns debugging information about the value as a string of comma-separated
* values in angle brackets with a leading #:
*
* BigDecimal.new("1234.5678").inspect ->
* "#<BigDecimal:b7ea1130,'0.12345678E4',8(12)>"
* BigDecimal.new("1234.5678").inspect
* #=> "#<BigDecimal:b7ea1130,'0.12345678E4',8(12)>"
*
* The first part is the address, the second is the value as a string, and
* the final part ss(mm) is the current number of significant digits and the
......
*
* Note that n must be an Integer.
*
* Also available as the operator **
* Also available as the operator **.
*/
static VALUE
BigDecimal_power(int argc, VALUE*argv, VALUE self)
......
}
/* call-seq:
* big_decimal ** exp -> big_decimal
* a ** n -> bigdecimal
*
* Returns the value raised to the power of n.
*
* It is a synonym of BigDecimal#power(exp).
* See BigDecimal#power.
*/
static VALUE
BigDecimal_power_op(VALUE self, VALUE exp)
(2-2/3)