Flowdock
method

truncate

Importance_1
Ruby latest stable (v1_9_3_392) - 0 notes - Class: BigDecimal
truncate(p1 = v1) public

Truncate to the nearest 1, returning the result as a BigDecimal.

BigDecimal(‘3.14159’).truncate -> 3

BigDecimal(‘8.7’).truncate -> 8

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’).truncate(3) -> 3.141

BigDecimal(‘13345.234’).truncate(-2) -> 13300.0

Show source
Register or log in to add new notes.