[GNC] Rounding & formulas

Peter West lists at pbw.id.au
Sun Dec 20 21:12:33 EST 2020


I don’t understand why "total_amount-(total_amount/2)” doesn’t work. I’m assuming that two formulae are used:
total_amount/2
&
total_amount-(total_amount/2),
as the OP specifies.

If the amount is odd, the first should be (given consistent truncation of the dividend by integer division) equivalent to
(total_amount -1) / 2,
which when subtracted from total_amount will leave an odd result. If it doesn’t do this, then there is a serious problem with Gnucash arithmetic.

Also, the OP isn’t trying to do accounting to the mille, but to the cent. The virtue of this is that everything balances, which is the whole point of double entry, I think. And if you’re vaguely obsessive, as I am, such virtue is its own reward.

God bless you all, and may you have a blessed and holy Christmas.

Peter
--
Peter West
pbw at pbw.id.au
“Blessed are you among women, and blessed is the fruit of your womb!”

> On 21 Dec 2020, at 11:15 am, Adrien Monteleone <adrien.monteleone at lusfiber.net> wrote:
> 
> Note, I'm not aware of a 'proper' solution that you are looking for.
> 
> Sounds like a lot of effort to avoid changing a single digit on review when occasionally the original amount is odd.
> 
> I would expect your try at "total_amount-(total_amount/2)" to only work half the time, thus a coin flip. Note, that's 29 characters. (not to count the clicks to get that far setting it up, or other characters involved) How many did you type asking this question? How much time and typing will you save, and if you find a solution, how long will it take to break even?
> 
> I'm not trying to be rude, but this is almost at the level of wanting to do accounting to the mille. The payoff will never be worth the effort.
> 
> Regards,
> Adrien
> 
> On 12/19/20 12:09 PM, Thomas Lenherr wrote:
>> Hi,
>> I've been using gnucash for a few years now, including scheduled
>> transactions with variables/formulas, but one thing I never figured out is
>> how to avoid imbalances in them when variables cause "bad" rounding,
>> requiring me to fix those manually.
>> Simple example:
>> I use a scheduled transaction for an expense that varies month to month
>> (=variable), and I'd like to split it into two (share with another person,
>> i.e. book 50% against their account). Every now and then that amount is an
>> odd number of cents, and so just dividing by two for both the amount
>> against my expense account and their debitor-account results in an
>> imbalance that I need to fix manually (= I'm fine always being the person
>> that pays a cent more than the other one).
>> I tried to be "clever" by writing one of them as "total_amount/2" and the
>> other one as "total_amount-(total_amount/2)" but that didn't work either.
>> Is there a way to e.g. force rounding in the formula? E.g. something like
>> "round(total_amount/2, 0.01)" and "total_amount - round(total_amount/2,
>> 0.01)"? Or is there a different solution I'm not aware of?
>> If there's no existing option, would it be hard to add support for such a
>> function or other solution?
> 
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> If you are using Nabble or Gmane, please see https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.



More information about the gnucash-user mailing list