Method: BigDecimal.save_rounding_mode

Defined in:
bigdecimal.c

.save_rounding_mode { ... } ⇒ Object

Execute the provided block, but preserve the rounding mode

BigDecimal.save_rounding_mode do
  BigDecimal.mode(BigDecimal::ROUND_MODE, :up)
  puts BigDecimal.mode(BigDecimal::ROUND_MODE)
end

For use with the BigDecimal::ROUND_*

See BigDecimal.mode

Yields:



3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
# File 'bigdecimal.c', line 3870

static VALUE
BigDecimal_save_rounding_mode(VALUE self)
{
    unsigned short const round_mode = VpGetRoundMode();
    int state;
    VALUE ret = rb_protect(rb_yield, Qnil, &state);
    VpSetRoundMode(round_mode);
    if (state) rb_jump_tag(state);
    return ret;
}