[moneydance] ProfitCalc extension build 3 and more

Sean Reilly sreilly at seanreilly.com
Thu May 4 09:09:02 EDT 2006


On May 1, 2006, at 9:07 PM, Edward Reid wrote:

> At 10:54 05/01/06 -0600, Jeff Poole wrote:
>> 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).
>
> The problem is not with binary, but with using binary FLOATING POINT.
> Floating point is inappropriate for storing monetary amounts (or any
> numbers with exact decimal fractions), since 1/5 cannot be exactly
> represented in binary floating point.
>
> The correct way of storing monetary amounts is to use an integer  
> (pick a
> type that's large enough for the amounts in question) and to save  
> the scale
> factor separately.

In fact, this is how Moneydance records all amounts.  It should be  
possible to do all the calculations in Moneydance without resorting  
to floating point, except for prices (which are secondary to the  
accuracy of all amounts).

Srini, if you are sticking to using the integer/long amounts then I  
would recommend using the CurrencyType.format*(long value, char  
decimalPoint) methods to display the values.

Thanks,
Sean


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2560 bytes
Desc: not available
Url : http://moneydance.com/pipermail/moneydance-info/attachments/20060504/4fb7a673/smime.bin


More information about the moneydance-info mailing list