diff options
author | John Wiegley <johnw@newartisans.com> | 2012-10-26 08:31:57 -0700 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-10-26 08:31:57 -0700 |
commit | 7cee6c559b8198aea9fc75a197bac7bc6e71eaeb (patch) | |
tree | fac4c09dba9035c01a25ad84bc4fd3d12fdaa4f7 /src/value.cc | |
parent | 34ca6b3991d63dd04d60286452399c7e0d49974b (diff) | |
parent | b044a74bd34afdc27baf6241fe398690ff5e043a (diff) | |
download | fork-ledger-7cee6c559b8198aea9fc75a197bac7bc6e71eaeb.tar.gz fork-ledger-7cee6c559b8198aea9fc75a197bac7bc6e71eaeb.tar.bz2 fork-ledger-7cee6c559b8198aea9fc75a197bac7bc6e71eaeb.zip |
Merge pull request #96 from enderw88/Bug634-floor-ceil-round
Bug 634 and 488, Corrected behavior of floor, and added ceiling
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()) { |