A first stab at budgeting

Darin Willits darin at blueyonder.co.uk
Wed Sep 17 14:05:25 CDT 2003


On Wed, 2003-09-17 at 12:17, Christian Stimming wrote:
> Wow, this looks really nice.
> 
> One of your open issues caught my eye:
> 
> Darin Willits schrieb:
> > - I don't really use the commodities yet although each category has
> > one.  Currently I just kinda fudge the calculations and use the value as
> > a float.  This will have to change once I figure out just how all that
> > commodity stuff actually works.
> 
> You are calculating with the amounts as *floats*? This is probably not a 
> good idea, since amount handling as float/double was dropped from 
> gnucash long ago because of rounding issues. The recommended way of 
> calculating amounts is as a gnc_numeric type. Drawback: The usual 
> arithmetic operations are no longer accessible as simply operators +-*/ 
> but instead they have to be written as function calls 
> gnc_numeric_add_fixed(a, b) from src/engine/gnc-numeric.h. Benefit: You 
> won't encouter any silent rounding errors anymore. And the interface to 
> the gnucash engine API can directly be used since gnc_numeric is used in 
> the engine all over the place. (If there are functions that still accept 
> doubles, they are probably clearly marked as deprecated and will be 
> removed soon.)
> 
> I.e. using the gnc_numeric data type is far more important than any 
> commodity considerations.
> 

Actually I probably worded this badly... a consequence of the time I
first wrote it.  I am *storing* everything as gnc_numeric but when I go
to display it I just convert it to a (double actually) floating point
value.  

As for the totals (inflow/outflow/balance), you are right.  I currently
convert my gnc_numeric to double add everything up and then display it. 
This will __have__ to change to the gnc_numeric_add() style but I am
still not sure how the commodity fits into all this (ie can you add two
numerics without considering the commodity??) so I wanted to wait to
tackle this issue till I had a better understanding of how things work
in the account world.

> Thanks a lot in any case. Keep up the good work.
> 

Thanks, I'll try! ;-)

Cheers,

Darin




More information about the gnucash-devel mailing list