Basic type for handling commoditized math: amount_t. More...
Go to the source code of this file.
Classes | |
class | ledger::amount_error |
class | ledger::amount_t |
Encapsulate infinite-precision commoditized amounts. More... | |
Namespaces | |
namespace | ledger |
Macros | |
Printing | |
#define | AMOUNT_PRINT_COLORIZE 0x02 |
#define | AMOUNT_PRINT_ELIDE_COMMODITY_QUOTES 0x08 |
#define | AMOUNT_PRINT_NO_COMPUTED_ANNOTATIONS 0x04 |
#define | AMOUNT_PRINT_NO_FLAGS 0x00 |
An amount may be output to a stream using the ‘print’ method. | |
#define | AMOUNT_PRINT_RIGHT_JUSTIFY 0x01 |
Typedefs | |
typedef flags::basic_t< parse_flags_enum_t, uint_least8_t > | ledger::parse_flags_t |
Enumerations | |
enum | ledger::parse_flags_enum_t { ledger::PARSE_DEFAULT = 0x00 , ledger::PARSE_PARTIAL = 0x01 , ledger::PARSE_SINGLE = 0x02 , ledger::PARSE_NO_MIGRATE = 0x04 , ledger::PARSE_NO_REDUCE = 0x08 , ledger::PARSE_NO_ASSIGN = 0x10 , ledger::PARSE_NO_ANNOT = 0x20 , ledger::PARSE_OP_CONTEXT = 0x40 , ledger::PARSE_SOFT_FAIL = 0x80 } |
Functions | |
std::ostream & | ledger::operator<< (std::ostream &out, const amount_t &amt) |
std::istream & | ledger::operator>> (std::istream &in, amount_t &amt) |
void | ledger::put_amount (property_tree::ptree &pt, const amount_t &amt, bool commodity_details=false) |
Basic type for handling commoditized math: amount_t.
An amount is the most basic numerical type in Ledger, and relies on commodity.h to represent commoditized amounts, which allows Ledger to handle mathematical expressions involving disparate commodities.
Amounts can be of virtually infinite size and precision. When division or multiplication is performed, the precision is automatically expanded to include as many extra digits as necessary to avoid losing information.
Definition in file amount.h.
#define AMOUNT_PRINT_NO_FLAGS 0x00 |
An amount may be output to a stream using the ‘print’ method.
There is also a global operator<< defined which simply calls print for an amount on the given stream. There is one form of the print method, which takes one required argument and two arguments with default values:
print(ostream, bool omit_commodity = false, bool full_precision = false) prints an amounts to the given output stream, using its commodity's default display characteristics. If ‘omit_commodity’ is true, the commodity will not be displayed, only the amount (although the commodity's display precision is still used). If ‘full_precision’ is true, the full internal precision of the amount is displayed, regardless of its commodity's display precision.