floor

floor(n) Instance Public methods Return the largest integer less than or equal to the value, as a BigDecimal. BigDecimal('3.14159').floor #=> 3 BigDecimal('-9.1').floor #=> -10 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').floor(3) #=> 3.141 BigDecimal('13345.234').floor(-2) #=>

fix

fix() Instance Public methods Return the integer part of the number.

finite?

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

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.

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

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.

div

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

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.

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

as_json

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