[Gnucash-changes] r13919 - gnucash/trunk/src/engine/test-core - Correctly ensure that the amount and value of test Splits have the same sign

Derek Atkins warlord at MIT.EDU
Fri May 5 08:50:52 EDT 2006


Chris Shoemaker <chris at cvs.gnucash.org> writes:

> Modified: gnucash/trunk/src/engine/test-core/test-engine-stuff.c
> ===================================================================
> --- gnucash/trunk/src/engine/test-core/test-engine-stuff.c	2006-05-04 09:18:39 UTC (rev 13918)
> +++ gnucash/trunk/src/engine/test-core/test-engine-stuff.c	2006-05-05 00:17:04 UTC (rev 13919)
> @@ -961,8 +961,7 @@
>          amt = val;
>      } else {
>          gnc_numeric amt2 = xaccSplitGetAmount(s);
> -        int i = gnc_numeric_positive_p(amt2) + gnc_numeric_positive_p(amt);
> -        if (i % 2)
> +        if (gnc_numeric_positive_p(amt2) ^ gnc_numeric_positive_p(val))
>              amt = gnc_numeric_neg(amt2);
>      }   

This seems rather confusing or convoluted.   Why not just run:

  if (gnc_numeric_positive_p(amt2) != gnc_numeric_positive_p(val))
   ...

Are there really multiple bits such that you need to xor?

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list