51 #include <glib-object.h> 126 #define GNC_NUMERIC_RND_MASK 0x0000000f 127 #define GNC_NUMERIC_DENOM_MASK 0x000000f0 128 #define GNC_NUMERIC_SIGFIGS_MASK 0x0000ff00 217 #define GNC_HOW_DENOM_SIGFIGS( n ) ( ((( n ) & 0xff) << 8) | GNC_HOW_DENOM_SIGFIG) 218 #define GNC_HOW_GET_SIGFIGS( a ) ( (( a ) & 0xff00 ) >> 8) 245 #define GNC_DENOM_AUTO 0 255 gnc_numeric gnc_numeric_create(gint64 num, gint64 denom)
265 gnc_numeric gnc_numeric_zero(
void)
267 return gnc_numeric_create(0, 1);
315 gint64 gnc_numeric_num(gnc_numeric a)
321 gint64 gnc_numeric_denom(gnc_numeric a)
383 gint64 denom, gint how);
391 gint64 denom, gint how);
395 gint64 denom, gint how);
403 gint64 denom, gint how);
413 gint64 denom, gint how);
429 gnc_numeric gnc_numeric_add_fixed(gnc_numeric a, gnc_numeric b)
440 gnc_numeric gnc_numeric_sub_fixed(gnc_numeric a, gnc_numeric b)
475 guint8 * max_decimal_places);
488 GType gnc_numeric_get_type(
void );
489 #define GNC_TYPE_NUMERIC (gnc_numeric_get_type ()) GNC_HOW_RND_NEVER was specified, but the result could not be converted to the desired denominator wit...
Never round at all, and signal an error if there is a fractional result in a computation.
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
gchar * gnc_num_dbg_to_string(gnc_numeric n)
Convert to string.
gnc_numeric double_to_gnc_numeric(double n, gint64 denom, gint how)
Convert a floating-point number to a gnc_numeric.
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
All arguments are required to have the same denominator, that denominator is to be used in the output...
GNCNumericErrorCode
Error codes.
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
gboolean gnc_numeric_to_decimal(gnc_numeric *a, guint8 *max_decimal_places)
Attempt to convert the denominator to an exact power of ten without rounding.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
Intermediate result overflow.
Use any denominator which gives an exactly correct ratio of numerator to denominator.
gint gnc_numeric_compare(gnc_numeric a, gnc_numeric b)
Returns 1 if a>b, -1 if b>a, 0 if a == b.
gchar * gnc_numeric_to_string(gnc_numeric n)
Convert to string.
gboolean gnc_numeric_negative_p(gnc_numeric a)
Returns 1 if a < 0, otherwise returns 0.
gnc_numeric gnc_numeric_reduce(gnc_numeric n)
Return input after reducing it by Greater Common Factor (GCF) elimination.
gdouble gnc_numeric_to_double(gnc_numeric n)
Convert numeric to floating-point value.
gnc_numeric gnc_numeric_invert(gnc_numeric num)
Invert a gnc_numeric.
gnc_numeric gnc_numeric_convert(gnc_numeric n, gint64 denom, gint how)
Change the denominator of a gnc_numeric value to the specified denominator under standard arguments '...
Find the least common multiple of the arguments' denominators and use that as the denominator of the ...
Reduce the result value by common factor elimination, using the smallest possible value for the denom...
gnc_numeric gnc_numeric_mul(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Multiply a times b, returning the product.
const char * gnc_numeric_errorCode_to_string(GNCNumericErrorCode error_code)
Returns a string representation of the given GNCNumericErrorCode.
gnc_numeric gnc_numeric_error(GNCNumericErrorCode error_code)
Create a gnc_numeric object that signals the error condition noted by error_code, rather than a numbe...
Argument is not a valid number.
gnc_numeric gnc_numeric_abs(gnc_numeric a)
Returns a newly created gnc_numeric that is the absolute value of the given gnc_numeric value...
gnc_numeric gnc_numeric_div(gnc_numeric x, gnc_numeric y, gint64 denom, gint how)
Division.
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b are exactly the same (have the same numerator and ...
gboolean gnc_numeric_positive_p(gnc_numeric a)
Returns 1 if a > 0, otherwise returns 0.
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a-b.
Truncate fractions (round toward zero)
Promote fractions (round away from zero)
GNC_HOW_DENOM_FIXED was specified, but argument denominators differed.
Round to the nearest integer, rounding toward zero when there are two equidistant nearest integers...
gnc_numeric gnc_numeric_from_string(const gchar *str)
Read a gnc_numeric from str, skipping any leading whitespace.
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
GNCNumericErrorCode gnc_numeric_check(gnc_numeric a)
Check for error signal in value.
Use unbiased ("banker's") rounding.
Round to the number of significant figures given in the rounding instructions by the GNC_HOW_DENOM_SI...
gint gnc_numeric_same(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Equivalence predicate: Convert both a and b to denom using the specified DENOM and method HOW...
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.