Miniscule Share Residuals

David T. sunfish62 at
Sat Oct 29 12:16:43 EDT 2016

Probably. As in, probably I did something wrong. (What else is new? )
When I first queried the database, it returned only integers when I calculated the shares, so I Googled to find out how to get some decimals. My solution was to multiply by 1.0, which yielded the aforementioned results. 
Specifically, my query included SUM (shares*1.0/shares_denom). This resulted in the residuals. 
So, what is the "rational" way to calculate the shares? 

  On Sat, Oct 29, 2016 at 19:00, John Ralls<jralls at> wrote:   
> On Oct 29, 2016, at 4:47 AM, David T. via gnucash-devel <gnucash-devel at> wrote:
> Hi,
> Next question regarding commodity data in my GnuCash file. 
> I ran a simple SQL query against the SQLite db to count up the total number of shares by commodity, and I ran into several commodities whose share total was in the range of  9.9475983006414e-14. I know that there was a discussion some time back about the vagaries of rounding, and I wonder whether I should attempt to clean up these inconsistencies and if so, how I should do that.


What does GnuCash show as the residual value in those accounts?

That number looks like you might have converted the rational numbers into floats, either in your query or in your post-processing. Don't do that, use rational arithmetic.

John Ralls  

More information about the gnucash-devel mailing list