Class | BigDecimal
In: | bigdecimal/lib/bigdecimal/util.rb bigdecimal/bigdecimal.c
Parent: | Numeric

### Methods

!= % * ** + +@ - -@ / < <= <=> == === > >= _dump _load abs add ceil coerce div divmod double_fig dup eql? exponent finite? fix floor frac hash induced_from infinite? inspect limit mode modulo mult nan? new nonzero? power precs quo remainder round sign split sqrt sub to_digits to_f to_i to_int to_r to_s truncate ver zero?

### Public Class methods

_load(p1)
double_fig()
induced_from(p1)
limit(...)
mode(...)
new(...)
ver()

**** BigDecimal version ****

[Source]

    /*
     *  **** BigDecimal version ****
     */
    static VALUE
    BigDecimal_version(VALUE self)
    {
        /*
         * 1.0.0: Ruby 1.8.0
         * 1.0.1: Ruby 1.8.1
        */
        return rb_str_new2("1.0.1");
    }

### Public Instance methods

!=(p1)
%(p1)
*(p1)
**(p1)
+(p1)
+@()
-(p1)
-@()
/(p1)
<(p1)
<=(p1)
<=>(p1)
==(p1)
===(p1)
>(p1)
>=(p1)
_dump(...)
abs()
add(p1, p2)
ceil(...)
coerce(p1)
div(...)
divmod(p1)
dup()
eql?(p1)
exponent()
finite?()
fix()
floor(...)
frac()
hash()
infinite?()
inspect()
modulo(p1)
mult(p1, p2)
nan?()
nonzero?()
power(p1)
precs()
quo(p1)
remainder(p1)
round(...)
sign()
split()
sqrt(p1)
sub(p1, p2)
to_digits()

to "nnnnnn.mmm" form digit string Use BigDecimal#to_s("F") instead.

[Source]

    # File bigdecimal/lib/bigdecimal/util.rb, line 35
      def to_digits
         if self.nan? || self.infinite? || self.zero?
            self.to_s
         else
           i       = self.to_i.to_s
           s,f,y,z = self.frac.split
           i + "." + ("0"*(-z)) + f
         end
      end

to_f()
to_i()
to_int()
to_r()

Convert BigDecimal to Rational

[Source]

    # File bigdecimal/lib/bigdecimal/util.rb, line 46
      def to_r
         sign,digits,base,power = self.split
         numerator = sign*digits.to_i
         denomi_power = power - digits.size # base is always 10
         if denomi_power < 0
            denominator = base ** (-denomi_power)
         else
            denominator = base ** denomi_power
         end
         Rational(numerator,denominator)
      end

to_s(...)
truncate(...)
zero?()

[Validate]