Hi Charles, On Mon, 2008-09-01 at 14:24 -0700, Charles Day wrote: > On Mon, Sep 1, 2008 at 1:57 PM, Christian Stimming <[EMAIL PROTECTED]> > wrote: > Am Montag, 1. September 2008 22:44 schrieb Charles Day: > > > > + fraction = converted_val.denom; > > > > + if (fraction <= 0) > > > > + return FALSE; > > > > > > out of curiosity, what is the reason for disallowing > negative > > > denominators? > > > My immediate reaction to this question: Denominators should be > positive so > that a comparison of equal numbers gives predictable results, > and also to > avoid any confusion about the actual meaning of a negative > denominator. > > > > I am not sure whether there is a gnc_numeric API function > > > to switch signs of nom and denom safely, but I am sure > that doing it is > > > possible :-) But maybe the current behavior is actually > desired. > > > > Honestly, I'm not 100% sure what negative denominators mean. > The function I > > added is essentially a modified version of > is_decimal_fraction() from > > app-utils/gnc-ui-utils.c, and since negative denominators > were not > > considered decimal numbers there, I did the same. > > > > On the other hand, I believe that a negative denominator of > -3 may actually > > mean a denominator equal to 1/3. So if a gnc_numeric of 5/-3 > is equal to > > 5/(1/3), then that is also equal to 5*3=15. > > > Uh oh? No, not at all, please. A negative denominator must > mean at most that > the sign of the rational number is changed from positive to > negative, or, if > the numerator is negative as well, the sign of the number is > changed from > negative to positive. No more, no less. As this doesn't make > much sense, it > is sensible to restrict the denominator to positive numbers > only. > > The gnc-numeric.c code seems to assume that only the numerator is > needed to determine sign. For example, gnc_numeric_positive_p() and > gnc_numeric_negative_p() only check the sign of the numerator. > > > > For sure negative numbers will and must never suddently turn > into the inverse > of a number. Negative != inverted. Really. Always. > > There are several mentions of "reciprocal" in gnc-numeric.c comments, > referring to a negative denominator. See gnc_numeric_compare() and > gnc_numeric_equal(), for example. They seem to be doing what I > suggested, i.e. 5/-3 == 15/1.
Indeed. There is also a documentation for the macro GNC_DENOM_RECIPROCAL. Rest assured that I profoundly dislike this "design choice". Fortunately, it does not seem to be in use (a lot). If possible, let us kill it, please. Ciao, -- andi5
signature.asc
Description: This is a digitally signed message part
_______________________________________________ gnucash-devel mailing list [email protected] https://lists.gnucash.org/mailman/listinfo/gnucash-devel
