[GNC] Rounding & formulas

Fred Bone Fred.Bone at dial.pipex.com
Mon Dec 21 07:38:55 EST 2020


On 21 December 2020 at 22:14, Peter West said:

> There’s no rounding as such involved in the formulae. The timing will
> only matter if total_amount changes between the two calculations, which I
> assume it will not do. If x/2, when x is an integer (be it number of cents
> or number of pennies or whatever), does not give identical results for the
> same x whenever it is executed, something is seriously wrong.
> 
> If x is a floating point number, odd things can happen. Even so, for the
> same x, the result must be constant. The developers should be able to
> clarify all of this.

Of course there is rounding, but no-one suggested it was visible in the 
formulae.

Half an odd number cannot be represented as a whole number and the end 
result is necessarily rounded either up or down. This is true even if the 
calculation is done in floating point rather than rational arithmetic.

As I said, much depends on whether the rounding occurs at the end (as I 
would expect, and as the OP's report suggests) or at each stage of the 
calculation (which is inconsistent with the OP's report).



More information about the gnucash-user mailing list