diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-30 16:19:31 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-30 16:19:31 -0400 |
commit | f1257cbc3eaddc075dcb4f9ebff17e4ea416c4ed (patch) | |
tree | ee13fa7f7e046735b8a267bef0a3525ccb343b12 /src | |
parent | 94004358705b8fbfbb3b18226804820b1dca565e (diff) | |
download | fork-ledger-f1257cbc3eaddc075dcb4f9ebff17e4ea416c4ed.tar.gz fork-ledger-f1257cbc3eaddc075dcb4f9ebff17e4ea416c4ed.tar.bz2 fork-ledger-f1257cbc3eaddc075dcb4f9ebff17e4ea416c4ed.zip |
Removed all dependency on gdtoa.
Diffstat (limited to 'src')
-rw-r--r-- | src/amount.cc | 12 | ||||
-rw-r--r-- | src/amount.h | 24 | ||||
-rw-r--r-- | src/balance.h | 6 | ||||
-rw-r--r-- | src/balpair.h | 2 | ||||
-rw-r--r-- | src/system.hh | 3 | ||||
-rw-r--r-- | src/value.h | 9 |
6 files changed, 4 insertions, 52 deletions
diff --git a/src/amount.cc b/src/amount.cc index d7a689cc..55a71521 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -223,8 +223,6 @@ void amount_t::_release() } -#ifdef HAVE_GDTOA - namespace { amount_t::precision_t convert_double(mpz_t dest, double val) { @@ -277,8 +275,6 @@ amount_t::amount_t(const double val) : commodity_(NULL) quantity->prec = convert_double(MPZ(quantity), val); } -#endif // HAVE_GDTOA - amount_t::amount_t(const unsigned long val) : commodity_(NULL) { TRACE_CTOR(amount_t, "const unsigned long"); @@ -683,8 +679,6 @@ bool amount_t::is_zero() const } -#ifdef HAVE_GDTOA - double amount_t::to_double(bool no_check) const { if (! quantity) @@ -716,8 +710,6 @@ double amount_t::to_double(bool no_check) const return value; } -#endif // HAVE_GDTOA - long amount_t::to_long(bool no_check) const { if (! quantity) @@ -735,16 +727,12 @@ long amount_t::to_long(bool no_check) const return value; } -#ifdef HAVE_GDTOA - bool amount_t::fits_in_double() const { double value = to_double(true); return *this == amount_t(value); } -#endif // HAVE_GDTOA - bool amount_t::fits_in_long() const { long value = to_long(true); diff --git a/src/amount.h b/src/amount.h index 8ea9c2af..2285591a 100644 --- a/src/amount.h +++ b/src/amount.h @@ -49,11 +49,6 @@ * division or multiplication is performed, the precision is * automatically expanded to include as many extra digits as necessary * to avoid losing information. - * - * Floating-point math is never used at any point in these routines. If - * floating-point numbers are used to create amounts, they are first - * rendered to decimal using David Gay's gdtoa library, and then parsed - * as multi-precision values. */ #ifndef _AMOUNT_H #define _AMOUNT_H @@ -80,14 +75,9 @@ DECLARE_EXCEPTION(amount_error, std::runtime_error); */ class amount_t : public ordered_field_operators<amount_t, -#ifdef HAVE_GDTOA ordered_field_operators<amount_t, double, -#endif ordered_field_operators<amount_t, unsigned long, - ordered_field_operators<amount_t, long> > > -#ifdef HAVE_GDTOA - > -#endif + ordered_field_operators<amount_t, long> > > > { public: /** Ready the amount subsystem for use. @@ -172,11 +162,9 @@ public: TRACE_CTOR(amount_t, ""); } -#ifdef HAVE_GDTOA /** Convert a double to an amount. As much precision as possible is decoded from the binary floating point number. */ amount_t(const double val); -#endif /** Convert an unsigned long to an amount. It's precision is zero. */ amount_t(const unsigned long val); @@ -251,11 +239,9 @@ public: be freed. */ amount_t& operator=(const amount_t& amt); -#ifdef HAVE_GDTOA amount_t& operator=(const double val) { return *this = amount_t(val); } -#endif amount_t& operator=(const unsigned long val) { return *this = amount_t(val); } @@ -506,18 +492,14 @@ public: been stripped and the full, internal precision of the amount would be displayed. */ -#ifdef HAVE_GDTOA double to_double(bool no_check = false) const; -#endif long to_long(bool no_check = false) const; string to_string() const; string to_fullstring() const; string quantity_string() const; -#ifdef HAVE_GDTOA - bool fits_in_double() const; -#endif - bool fits_in_long() const; + bool fits_in_double() const; + bool fits_in_long() const; /*@}*/ diff --git a/src/balance.h b/src/balance.h index 37641836..8f565e78 100644 --- a/src/balance.h +++ b/src/balance.h @@ -115,13 +115,11 @@ public: if (! amt.is_realzero()) amounts.insert(amounts_map::value_type(&amt.commodity(), amt)); } -#ifdef HAVE_GDTOA balance_t(const double val) { TRACE_CTOR(balance_t, "const double"); amounts.insert (amounts_map::value_type(amount_t::current_pool->null_commodity, val)); } -#endif balance_t(const unsigned long val) { TRACE_CTOR(balance_t, "const unsigned long"); amounts.insert @@ -236,11 +234,9 @@ public: virtual balance_t& operator*=(const amount_t& amt); -#ifdef HAVE_GDTOA balance_t& operator*=(const double val) { return *this *= amount_t(val); } -#endif balance_t& operator*=(const unsigned long val) { return *this *= amount_t(val); } @@ -250,11 +246,9 @@ public: virtual balance_t& operator/=(const amount_t& amt); -#ifdef HAVE_GDTOA balance_t& operator/=(const double val) { return *this /= amount_t(val); } -#endif balance_t& operator/=(const unsigned long val) { return *this /= amount_t(val); } diff --git a/src/balpair.h b/src/balpair.h index 3f83df96..90103c1e 100644 --- a/src/balpair.h +++ b/src/balpair.h @@ -113,11 +113,9 @@ public: : balance_t(amt), cost(cost_amt) { TRACE_CTOR(balance_pair_t, "const amount_t&, const amount_t&"); } -#ifdef HAVE_GDTOA balance_pair_t(const double val) : balance_t(val) { TRACE_CTOR(balance_pair_t, "const double"); } -#endif balance_pair_t(const unsigned long val) : balance_t(val) { TRACE_CTOR(balance_pair_t, "const unsigned long"); } diff --git a/src/system.hh b/src/system.hh index 1096271b..7978119f 100644 --- a/src/system.hh +++ b/src/system.hh @@ -121,9 +121,6 @@ typedef std::ostream::pos_type ostream_pos_type; #endif #include <gmp.h> -#ifdef HAVE_GDTOA -#include "gdtoa.h" -#endif #include "SHA1.h" #include "irrXML.h" // XML parser diff --git a/src/value.h b/src/value.h index dbb83283..393ca3d3 100644 --- a/src/value.h +++ b/src/value.h @@ -78,14 +78,9 @@ class value_t multiplicative<value_t, balance_pair_t, multiplicative<value_t, balance_t, ordered_field_operators<value_t, amount_t, -#ifdef HAVE_GDTOA ordered_field_operators<value_t, double, -#endif ordered_field_operators<value_t, unsigned long, - ordered_field_operators<value_t, long> > > > > > > > > > -#ifdef HAVE_GDTOA - > -#endif + ordered_field_operators<value_t, long> > > > > > > > > > > { public: /** @@ -288,12 +283,10 @@ public: TRACE_CTOR(value_t, "const unsigned long"); set_amount(val); } -#ifdef HAVE_GDTOA value_t(const double val) { TRACE_CTOR(value_t, "const double"); set_amount(val); } -#endif value_t(const amount_t& val) { TRACE_CTOR(value_t, "const amount_t&"); set_amount(val); |