// -1 -> 10's digit, -2 -> 100's digit, etc.
BigDecimal normalized = value.movePointRight(scale);
// ...round to that digit
BigDecimal rounded = normalized.setScale(0, mode);
// ...and shift the result back to the left (multiply by 10**(abs(scale)))
bigDecimal = new RubyBigDecimal(getRuntime(), rounded.movePointLeft(scale));
} else {
bigDecimal = new RubyBigDecimal(getRuntime(), value.setScale(scale, mode));
}
if (args.length == 0) {
return bigDecimal.to_int();