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

Allan agander93 at gmail.com
Tue Oct 9 21:44:42 UTC 2012


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


More information about the KMyMoney-devel mailing list