summaryrefslogtreecommitdiff
path: root/src/amount.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-01-30 19:30:16 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-01-30 19:30:16 -0400
commite0dd2cd0a44ddbfabadb30da4569e10fd36960a9 (patch)
tree74e691cce67fbc1e975c918d2acb34733b1fd857 /src/amount.h
parent6213dc5af8b365cde2495fddaa465b0427779d00 (diff)
downloadfork-ledger-e0dd2cd0a44ddbfabadb30da4569e10fd36960a9.tar.gz
fork-ledger-e0dd2cd0a44ddbfabadb30da4569e10fd36960a9.tar.bz2
fork-ledger-e0dd2cd0a44ddbfabadb30da4569e10fd36960a9.zip
Changed to using rational numbers instead of integer approximations.
As a result, dependency on the gdtoa was dropped, and dependency on mpfr was added.
Diffstat (limited to 'src/amount.h')
-rw-r--r--src/amount.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/amount.h b/src/amount.h
index ba7d1c07..906aef0b 100644
--- a/src/amount.h
+++ b/src/amount.h
@@ -57,6 +57,11 @@
namespace ledger {
+// If defined, amount.cc uses GMP integers rather than rationals.
+// Ledger 3.0 uses rationals, but 2.6 and before used integers, so this
+// provides a quick way of testing against past numerical behavior.
+//#define INTEGER_MATH 1
+
class commodity_t;
class annotation_t;
class commodity_pool_t;
@@ -318,6 +323,9 @@ public:
amount.commodity().precision()
@endcode */
precision_t precision() const;
+ bool keep_precision() const;
+ void set_keep_precision(const bool keep = true) const;
+ precision_t display_precision(const bool full_precision = false) const;
/** Returns the negated value of an amount.
@see operator-()
@@ -344,6 +352,8 @@ public:
return *this;
}
+#ifdef INTEGER_MATH
+
/** An amount's internal value to the given precision, or to the
commodity's current display precision if no precision value is
given. This method changes the internal value of the amount, if
@@ -363,6 +373,8 @@ public:
}
amount_t& in_place_round(precision_t prec);
+#endif // INTEGER_MATH
+
/** Yields an amount whose display precision is never truncated, even
though its commodity normally displays only rounded values.
*/