GnuCash
2.6.99
|
An exact-rational-number library for gnucash. (to be renamed qofnumeric.h in libqof2) More...
#include <glib-object.h>
Go to the source code of this file.
Data Structures | |
struct | _gnc_numeric |
Typedefs | |
typedef struct _gnc_numeric | gnc_numeric |
An rational-number type. More... | |
Arguments Standard Arguments to most functions | |
Most of the gnc_numeric arithmetic functions take two arguments in addition to their numeric args: 'denom', which is the denominator to use in the output gnc_numeric object, and 'how'. which describes how the arithmetic result is to be converted to that denominator. This combination of output denominator and rounding policy allows the results of financial and other rational computations to be properly rounded to the appropriate units. Watch out: You must specifiy a rounding policy such as GNC_HOW_RND_NEVER, otherwise the fractional part of the input value might silently get discarded! Valid values for denom are: GNC_DENOM_AUTO – compute denominator exactly integer n – Force the denominator of the result to be this integer GNC_DENOM_RECIPROCAL – Use 1/n as the denominator (???huh???) Valid values for 'how' are bitwise combinations of zero or one "rounding instructions" with zero or one "denominator types". Valid rounding instructions are: GNC_HOW_RND_FLOOR GNC_HOW_RND_CEIL GNC_HOW_RND_TRUNC GNC_HOW_RND_PROMOTE GNC_HOW_RND_ROUND_HALF_DOWN GNC_HOW_RND_ROUND_HALF_UP GNC_HOW_RND_ROUND GNC_HOW_RND_NEVER The denominator type specifies how to compute a denominator if GNC_DENOM_AUTO is specified as the 'denom'. Valid denominator types are: GNC_HOW_DENOM_EXACT GNC_HOW_DENOM_REDUCE GNC_HOW_DENOM_LCD GNC_HOW_DENOM_FIXED GNC_HOW_DENOM_SIGFIGS(N) To use traditional rational-number operational semantics (all results are exact and are reduced to relatively-prime fractions) pass the argument GNC_DENOM_AUTO as 'denom' and GNC_HOW_DENOM_REDUCE| GNC_HOW_RND_NEVER as 'how'. To enforce strict financial semantics (such that all operands must have the same denominator as each other and as the result), use GNC_DENOM_AUTO as 'denom' and GNC_HOW_DENOM_FIXED | GNC_HOW_RND_NEVER as 'how'. | |
#define | GNC_NUMERIC_RND_MASK 0x0000000f |
bitmasks for HOW flags. More... | |
#define | GNC_NUMERIC_DENOM_MASK 0x000000f0 |
#define | GNC_NUMERIC_SIGFIGS_MASK 0x0000ff00 |
#define | GNC_HOW_DENOM_SIGFIGS(n) ( ((( n ) & 0xff) << 8) | GNC_HOW_DENOM_SIGFIG) |
#define | GNC_HOW_GET_SIGFIGS(a) ( (( a ) & 0xff00 ) >> 8) |
#define | GNC_DENOM_AUTO 0 |
#define | GNC_DENOM_RECIPROCAL(a) (- ( a )) |
enum | { GNC_HOW_RND_FLOOR = 0x01, GNC_HOW_RND_CEIL = 0x02, GNC_HOW_RND_TRUNC = 0x03, GNC_HOW_RND_PROMOTE = 0x04, GNC_HOW_RND_ROUND_HALF_DOWN = 0x05, GNC_HOW_RND_ROUND_HALF_UP = 0x06, GNC_HOW_RND_ROUND = 0x07, GNC_HOW_RND_NEVER = 0x08 } |
Rounding/Truncation modes for operations. More... | |
enum | { GNC_HOW_DENOM_EXACT = 0x10, GNC_HOW_DENOM_REDUCE = 0x20, GNC_HOW_DENOM_LCD = 0x30, GNC_HOW_DENOM_FIXED = 0x40, GNC_HOW_DENOM_SIGFIG = 0x50 } |
enum | GNCNumericErrorCode { GNC_ERROR_OK = 0, GNC_ERROR_ARG = -1, GNC_ERROR_OVERFLOW = -2, GNC_ERROR_DENOM_DIFF = -3, GNC_ERROR_REMAINDER = -4 } |
GValue | |
#define | GNC_TYPE_NUMERIC (gnc_numeric_get_type ()) |
GType | gnc_numeric_get_type (void) |
An exact-rational-number library for gnucash. (to be renamed qofnumeric.h in libqof2)
Definition in file gnc-numeric.h.