to_f

to_f() Instance Public methods Returns a new Float object having approximately the same value as the BigDecimal number. Normal accuracy limits and built-in errors of binary Float arithmetic apply.

to_digits

a.to_digits â string Instance Public methods Converts a BigDecimal to a String of the form ânnnnnn.mmmâ. This method is deprecated; use #to_s(âFâ) instead. require 'bigdecimal' require 'bigdecimal/util' d = BigDecimal.new("3.14") d.to_digits # => "3.14"

to_d

a.to_d â bigdecimal Instance Public methods Returns self.

sub

sub(p1, p2) Instance Public methods

sqrt

sqrt(n) Instance Public methods Returns the square root of the value. Result has at least n significant digits.

split

split() Instance Public methods Splits a BigDecimal number into four parts, returned as an array of values. The first value represents the sign of the BigDecimal, and is -1 or 1, or 0 if the BigDecimal is Not a Number. The second value is a string representing the significant digits of the BigDecimal, with no leading zeros. The third value is the base used for arithmetic (currently always 10) as an Integer. The fourth value is an Integer exponent. If the BigDecimal can be represent

sign

sign() Instance Public methods Returns the sign of the value. Returns a positive value if > 0, a negative value if < 0, and a zero if == 0. The specific value returned indicates the type and sign of the BigDecimal, as follows: BigDecimal::SIGN_NaN value is Not a Number BigDecimal::SIGN_POSITIVE_ZERO value is +0 BigDecimal::SIGN_NEGATIVE_ZERO value is -0 BigDecimal::SIGN_POSITIVE_INFINITE value is +infinity BigDecimal::SIGN_NEGATIVE_INFINITE value is -infinity B

round

round(n, mode) Instance Public methods Round to the nearest 1 (by default), returning the result as a BigDecimal. BigDecimal('3.14159').round #=> 3 BigDecimal('8.7').round #=> 9 If n is specified and positive, the fractional part of the result has no more than that many digits. If n is specified and negative, at least that many digits to the left of the decimal point will be 0 in the result. BigDecimal('3.14159').round(3) #=> 3.142 BigDecimal('13345.234').round(-2) #=>

remainder

remainder(p1) Instance Public methods Returns the remainder from dividing by the value. x.remainder(y) means x-y*(x/y).truncate

quo

quo(value) Instance Public methods Divide by the specified value. e.g. 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 ::mode. If digits is 0, the result is the same as the / operator. If not, the result is an integer BigDecimal, by analogy with Numeric#div. The alias quo is provided since div(value, 0) is the same as computing the quotient; see #divmod.