Rounding problem with stock split factor

Thomas Baumgart thb at net-bembel.de
Tue Jan 1 09:28:33 GMT 2019


Mark,

On Dienstag, 1. Januar 2019 09:56:47 CET Mark Thomas wrote:

> Hi,
> 
> I have a stock that has had a 6:1 share consolidation, so would reduce the
> quantity down to one for every 6 currently held.
> 
> I tried entering this as a "Split Shares" activity with a factor of 0.16667
> but this causes a divide by zero floating point exception,  see below for
> the backtrace.  Its the same in 5.0.1 and 5.0.2.
> 
> The critical point is that the stock is defined with  a 1/1 fraction (ie:
> whole stocks) and that this causes the split factor in the activity to be
> rounded down to zero.
> 
> This rounding  is also an issue with normal splits of whole stocks, for
> example a 3:2 split entered as factor 1.5 as per the manual is rounded up
> to 2.
> 
> The problem code appears to be in in
> kmymoney/dialogs/investtransactioneditor.cpp where
> InvestTransactionEditor::createTransaction() calls:
> 
> s0.setShares(MyMoneyMoney(s0.shares().convertDenominator(securityFraction,
> roundingMethod)));
> 
> with securityFraction is 1 but the value in s0 is the factor, not the total
> quantity of shares, and needs to keep the precision it was entered with.
> 
> I think the rounding should be done later on the new balance of shares
> after the split factor is applied and not on the factor itself.
> 
> It does look like an issue to me but this is the first time I've delved
> into the code.

Thanks for the detailed investigation. Indeed, this is a problem. Can you open a bug report on https://bugs.kde.org/enter_bug.cgi?product=kmymoney&format=guided, please? Please attach all the information you can provide (maybe a small sample file to reproduce the problem, the backtrace, etc.)


-- 

Regards

Thomas Baumgart

https://www.signal.org/       Signal, the better WhatsApp
-------------------------------------------------------------
If debugging is the process of removing bugs, then programming
must be the process of putting them in. -- Edsger W. Dijkstra
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 868 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20190101/e58dc687/attachment.sig>


More information about the KMyMoney-devel mailing list