From 74e569e220bee08d6c9eda59b5e4021748344994 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 26 Feb 2009 00:10:08 -0400 Subject: Added a truncated() method for amounts and values When an amount is truncated, it drops all of the extra precision and becomes exactly the value would have seen were it printed. --- src/amount.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/amount.h') diff --git a/src/amount.h b/src/amount.h index b6ca6d16..90f1359c 100644 --- a/src/amount.h +++ b/src/amount.h @@ -322,6 +322,12 @@ public: @see set_keep_precision */ amount_t rounded() const; + /** Yields an amount which has lost all of its extra precision, beyond what + the display precision of the commodity would have printed. */ + amount_t truncated() const { + return amount_t(to_string()); + } + /** Yields an amount whose display precision is never truncated, even though its commodity normally displays only rounded values. */ amount_t unrounded() const; -- cgit v1.2.3