Thanks everyone for the patience and the help, I think I have a fairly good grasp now on what changes I need to make to get things rolling again. It is quit shameful the amount of basic math skills you lose when you don't use them, but that is an entirely different story. :)<div>
<br></div><div>Thomas:</div><div><br></div><div>Thanks for the warning on the rounding issues, I saw this earlier when first developing the port and had come up with a good work around but it won't work now, so I will have to look at the library and see if something different will work better. I am sure there are ways to import C libraries into my project but I am not sure how, so for now I will be sticking to trying to implement what has been done in Java.</div>
<div><br></div><div>Thanks again to everyone for all the help on this project, it is moving along very well finally and hopefully will become more solid in the coming months.</div><div><br></div><div>-Eric<br><br><div class="gmail_quote">
On Wed, Oct 10, 2012 at 1:41 AM, Thomas Baumgart <span dir="ltr"><<a href="mailto:thb@net-bembel.de" target="_blank">thb@net-bembel.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Eric,<br>
<br>
basically, Allen explained the math behind the operation, and we all remember<br>
it from school: reducing a fraction. (More inline).<br>
<div class="im"><br>
On Tuesday 09 October 2012 17:11:42 you wrote:<br>
<br>
> Hi Thomas:<br>
><br>
> Thanks for taking the time to give me such a detailed explanation! Can you<br>
> maybe walk me through a few examples that I can try and use as a reference?<br>
> I finally can see that what I should have been doing from the start is take<br>
> the fraction that is stored in the balance column and just do the division<br>
> on that to come up with my correct "value". That is simple enough and<br>
> really I am not sure how I missed it.<br>
><br>
> What I can't figure out, even after trying to apply your explanation, is<br>
> how I am seeing values like below in my balance columns.<br>
><br>
> balance          balanceFormatted<br>
> -3133/25               -125.32<br>
> 726071/50          14521.42<br>
> 66919/25              2676.76<br>
><br>
> Since I know most of the time I have the actual value from the user as a<br>
> string, how to I take that value and apply the formatMoney() methods to get<br>
> to the fraction side? I am struggling trying to take my -125.32 and<br>
> returning the fraction of -3133/25.<br>
><br>
> If you can walk me through some of these that would be fantastic!<br>
<br>
</div>That is hidden in the MyMoneyMoney string ctor:<br>
<br>
MyMoneyMoney::MyMoneyMoney(const QString& pszAmount)<br>
    : AlkValue(pszAmount, _decimalSeparator)<br>
{<br>
}<br>
<br>
which calls the AlkValue ctor. It can be used to convert a formatted string<br>
into a rational value. See testcases in alkvaluetest.cpp, method<br>
AlkValueTest::stringCtor()<br>
<br>
The actual logic is inside the libgmp code in the string assignment e.g.<br>
<br>
      d->m_val = qPrintable(QString);    or<br>
      d->m_val = mpq_class(qPrintable(QString));<br>
<br>
where d->m_val is of type "mpq_class" and qPrintable returns a "char *"<br>
<br>
      d->m_val.canonicalize()<br>
<br>
reduces the rational to its smallest representation by removing common factors<br>
found in numerator and denominator (<a href="http://gmplib.org/manual/Rational-Number-
Functions.html#Rational-Number-Functions" target="_blank">http://gmplib.org/manual/Rational-Number-<br>
Functions.html#Rational-Number-Functions</a>).<br>
<br>
In case you don't use this library you will have to mimic the logic. Allen<br>
gave an example on how to do that. Be aware of any rounding problems. They<br>
usually show up when dealing with multiplication of any sort (multiple<br>
currencies, share value, etc.) in conjunction with addition. You have been<br>
warned.<br>
<div class="im"><br>
--<br>
<br>
Regards<br>
<br>
Thomas Baumgart<br>
<br>
GPG-FP: E55E D592 F45F 116B 8429   4F99 9C59 DB40 B75D D3BA<br>
-------------------------------------------------------------<br>
</div>I used to be a hypochondriac AND a kleptomaniac. So I took something for it.<br>
-------------------------------------------------------------<br>
</blockquote></div><br></div>