abs

abs() Instance Public methods Returns the absolute value. BigDecimal('5').abs -> 5 BigDecimal('-3').abs -> 3

add

add(value, digits) Instance Public methods + Add the specified value. e.g. c = a.add(b,n) 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 ::mode.

as_json

as_json(*) Instance Public methods Marshal the object to JSON. method used for JSON marshalling support.

ceil

ceil(n) Instance Public methods Return the smallest integer greater than or equal to the value, as a BigDecimal. BigDecimal('3.14159').ceil #=> 4 BigDecimal('-9.1').ceil #=> -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').ceil(3) #=> 3.142 BigDecimal('13345.234').ceil(-2) #=> 1

coerce

coerce(p1) Instance Public methods The coerce method provides support for Ruby type coercion. It is not enabled by default. This means that binary operations like + * / or - can often be performed on a BigDecimal and an object of another type, if the other object can be coerced into a BigDecimal value. e.g. a = ::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.

div

div(p1, p2 = v2) Instance Public methods See #quo

divmod

divmod(p1) Instance Public methods 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' a = ::new(â42â) b = ::new(â9â) q,m = a.divmod(b) c = q * b + m 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.

eql?

eql?(p1) Instance Public methods Tests for value equality; returns true if the values are equal. The == and === operators and the eql? method have the same implementation for BigDecimal. Values may be coerced to perform the comparison: ::new('1.0') == 1.0 -> true

exponent

exponent() Instance Public methods Returns the exponent of the BigDecimal number, as an Integer. If the number can be represented as 0.xxxxxx*10**n where xxxxxx is a string of digits with no leading zeros, then n is the exponent.

finite?

finite?() Instance Public methods Returns True if the value is finite (not NaN or infinite)