From b044a74bd34afdc27baf6241fe398690ff5e043a Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Thu, 25 Oct 2012 22:28:26 -0700 Subject: Bug 634 and 488, Corrected behavior of floor, and added ceiling This is only a partial fix for 634, since rounding is not fixed. --- src/value.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/value.cc') diff --git a/src/value.cc b/src/value.cc index 1921d5a3..c57cff78 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1658,6 +1658,29 @@ void value_t::in_place_floor() throw_(value_error, _f("Cannot floor %1%") % label()); } +void value_t::in_place_ceiling() +{ + switch (type()) { + case INTEGER: + return; + case AMOUNT: + as_amount_lval().in_place_ceiling(); + return; + case BALANCE: + as_balance_lval().in_place_ceiling(); + return; + case SEQUENCE: + foreach (value_t& value, as_sequence_lval()) + value.in_place_ceiling(); + return; + default: + break; + } + + add_error_context(_f("While ceiling %1%:") % *this); + throw_(value_error, _f("Cannot ceiling %1%") % label()); +} + void value_t::in_place_unround() { switch (type()) { -- cgit v1.2.3