diff options
author | Craig Earls <enderw88@gmail.com> | 2012-10-25 22:28:26 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2012-10-25 22:28:26 -0700 |
commit | b044a74bd34afdc27baf6241fe398690ff5e043a (patch) | |
tree | 6cf2168e51611a86e04d834b2a507322a8a8fe04 /src/value.cc | |
parent | 4b261f99bc56853b3468a8a1bb5b4af39ed67af5 (diff) | |
download | fork-ledger-b044a74bd34afdc27baf6241fe398690ff5e043a.tar.gz fork-ledger-b044a74bd34afdc27baf6241fe398690ff5e043a.tar.bz2 fork-ledger-b044a74bd34afdc27baf6241fe398690ff5e043a.zip |
Bug 634 and 488, Corrected behavior of floor, and added ceiling
This is only a partial fix for 634, since rounding is not fixed.
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 23 |
1 files changed, 23 insertions, 0 deletions
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()) { |