[Kmymoney-devel] [Android Port] Help with computing the account balance

Eric Bonney mailinglists at vanhlebarsoftware.com
Tue Oct 9 22:49:22 UTC 2012


Thanks Allan,

I can easily just leave it at say -123.32/100 and it will work too but was
hoping to work more like KMM and I can't figure out how you jumped from the
12352/100 to 6266/50 then down to 3133/25.

Did you just get the GCD and then divide by that?

Eric
On Oct 9, 2012 5:44 PM, "Allan" <agander93 at gmail.com> wrote:

> On 09/10/12 22:11, Eric Bonney wrote:
>
>> Hi Thomas:
>>
>> Thanks for taking the time to give me such a detailed explanation! Can
>> you maybe walk me through a few examples that I can try and use as a
>> reference? I finally can see that what I should have been doing from the
>> start is take the fraction that is stored in the balance column and just
>> do the division on that to come up with my correct "value". That is
>> simple enough and really I am not sure how I missed it.
>>
>> What I can't figure out, even after trying to apply your explanation, is
>> how I am seeing values like below in my balance columns.
>>
>> balance          balanceFormatted
>> -3133/25               -125.32
>> 726071/50          14521.42
>> 66919/25              2676.76
>>
>> Since I know most of the time I have the actual value from the user as a
>> string, how to I take that value and apply the formatMoney() methods to
>> get to the fraction side? I am struggling trying to take my -125.32 and
>> returning the fraction of -3133/25.
>>
>> If you can walk me through some of these that would be fantastic!
>>
>> Thanks again for all the help.
>> -Eric
>>
>
> I'm not an expert, but in case Thomas is tied up, this seems to be a
> possibility.
>
> Multiply by 100 to eliminate the decimal fraction (Can't remember, if I
> ever knew, the proper maths terminology).
>
> 125.32 = 125.32 * 100/100 = 12532/100 = 6266/50 = 3133/25
>
> 14521.42 = 14521.42 * 100/100 = 1452142/100 = 726071/50
>
> If that makes it more confusing, apologies.
>
> Allan
> ______________________________**_________________
> KMyMoney-devel mailing list
> KMyMoney-devel at kde.org
> https://mail.kde.org/mailman/**listinfo/kmymoney-devel<https://mail.kde.org/mailman/listinfo/kmymoney-devel>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20121009/a40278cc/attachment.html>


More information about the KMyMoney-devel mailing list