summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc
index 94bcfb20..75d09441 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -1296,6 +1296,29 @@ value_t value_t::rounded() const
return NULL_VALUE;
}
+value_t value_t::truncated() const
+{
+ switch (type()) {
+ case INTEGER:
+ return *this;
+ case AMOUNT:
+ return as_amount().truncated();
+ case BALANCE:
+ return as_balance().truncated();
+ case SEQUENCE: {
+ value_t temp;
+ foreach (const value_t& value, as_sequence())
+ temp.push_back(value.truncated());
+ return temp;
+ }
+ default:
+ break;
+ }
+
+ throw_(value_error, _("Cannot truncate %1") << label());
+ return NULL_VALUE;
+}
+
value_t value_t::unrounded() const
{
switch (type()) {