[moneydance] ProfitCalc extension build 3 and more
Jeff Poole
korvus at tasam.com
Mon May 1 12:54:26 EDT 2006
The formatting problem is due to the fact that computers store numbers in
binary, and there is no exact representation for 0.568 in binary (at
least, not in the 54 bits you get to represent it for a double precision
floating point number). When you try to get it, you end up with something
like this:
1/2 + 0/(2^2) + 0/(2^3) + 1/(2^4) + 0/(2^5) + 0/(2^6) + 0/(2^7) + 1/(2^8)
+ 0/(2^9) + 1/(2^10) + 1/(2^11) + 0/(2^12) + 1/(2^13) + 0/(2^14) +
0/(2^15) + 0/(2^16) + 0/(2^17) + 1/(2^18) + 1/(2^19) + 1/(2^20) + 0/(2^21)
+ 0/(2^22) + 1/(2^23) + 0/(2^24) + 1/(2^25) + 0/(2^26) + 1/(2^27) +
1/(2^28) + 0/(2^29) + 0/(2^30) + 0/(2^31) + 0/(2^32) + 0/(2^33) + 0/(2^34)
+ 1/(2^35) + 0/(2^36) + 0/(2^37) + 0/(2^38) + 0/(2^39) + 0/(2^40) +
1/(2^41) + 1/(2^42) + 0/(2^43) + 0/(2^44) + 0/(2^45) + 1/(2^46) + 0/(2^47)
+ 0/(2^48) + 1/(2^49) + 0/(2^50) + 0/(2^51) + 1/(2^52) + 1/(2^53) +
1/(2^54)
~.56800000000000000488
(this result is slightly different than that shown below, partially
because I didn't include the "36" which takes a few bits)
The options are either to round the number (which might make sense, but do
you always know the correct number of digits to round to?) or to use an
arbitrary precision decimal class, such as BigDecimal (
http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html ) to do
the math, as it stores the number as two integers -- a value, and the
number of decimal digits present. I am sure Sean has run into this
before, as it is a common problem when doing math on a computer.
Jeff
> Date: Sun, 30 Apr 2006 09:49:33 +0530
> From: Srini <srini.listmail at gmail.com>
> Subject: Re: [moneydance] ProfitCalc extension build 3 and more
> To: "General discussion related to Moneydance"
> <moneydance-info at moneydance.com>
> Message-ID:
> <1728726f0604292119n3554b041w395c94610b0f1628 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi Marc
>
> DivReinvest is indeed used for the calculations. It will not be included
> under Dividend, but is added to the total shares/units outstanding (since
> the dividend is reinvested as shares/units). I have double checked this.
> If its not working for you, then I would need some more details from you
> on
> the transaction/type etc to figure it out. I just retested this with some
> of my own transactions and it works.
>
> The formatting is something I am aware of and happens some times (I guess
> its got to do with Java precision), am figuring out in what all instances
> this happens, as the code written seems to account for all situations (but
> is obviously not!)
>
> Cheers
> Srini
>
> On 4/29/06, Marc Kaulisch <marc at kaulisch.de> wrote:
>>
>> Hi Srini,
>>
>> thanks again for your great tool.
>>
>> I have now installed version 3 of the Profit Calculator but still
>> dividends I have reinvested (DivReinvest) are not shown in the
>> calculation.
>>
>> Another bug is that with some fonds the amount of shares is calculated
>> wrongly:
>> For example: Moneydance gives the correct amouynt (36.568)
>> The Profit Calculator comes to 36.568000000000004
>>
>> Greetings,
>>
>>
>> Marc
>>
More information about the moneydance-info
mailing list