gnc-numeric overflow and bugs 603426, 612467, 587875
clif at eugeneweb.com
clif at eugeneweb.com
Thu Jan 13 04:36:55 EST 2011
Greetings,
I've been happily useing gnucash for many years. I just ran accross a
problem with the advanced portfolio report esentially the same as in Bugs
603426, 612467, and 587875.
In the middle of calculating the basis in basis-builder there is an
overflow in gnc-numeric-add. It happens in the first section commented as:
;; we have value and positive units, add units to basis
The debugging printout goes something like this:
* 09:19:25 DEBUG <gnc.scm> going in to basis list ((#<<gnc-numeric> num:
4855480 denom: 10000> . #<<gnc-numeric> num: 1073565383194004945 denom:
33935498851359267>))#<<gnc-numeric> num: 39210 denom:
10000>#<<gnc-numeric> num: 11896 denom: 100>
* 09:19:25 DEBUG <gnc.scm> actually in basis-builder
* 09:19:25 DEBUG <gnc.scm> b-list is ((#<<gnc-numeric> num: 4855480 denom:
10000> . #<<gnc-numeric> num: 1073565383194004945 denom:
33935498851359267>)) b-units is #<<gnc-numeric> num: 39210 denom: 10000>
b-value is #<<gnc-numeric> num: 11896 denom: 100> b-method is
average-basis
* 09:19:25 DEBUG <gnc.scm> value, pos units, average-basis
* 09:19:25 DEBUG <gnc.scm> new-units #<<gnc-numeric> num: 4894690 denom:
10000> new-tmp-mul #<<gnc-numeric> num: 6363128963367708899 denom:
414251694962881> new-value-num #<<gnc-numeric> num: -2 denom: 0>
new-value-denom #<<gnc-numeric> num: 4894690 denom: 10000>
* 09:19:25 DEBUG <gnc.scm> coming out of basis list ((#<<gnc-numeric> num:
4894690 denom: 10000> . #<<gnc-numeric> num: -1 denom: 0>))
When it's calculating the new value part (cdr) of the b-list it gets an
overflow when summing the parts of the numerator together. eg here:
(gnc-numeric-add b-value (gnc-numeric-mul (caar b-list) (cdar b-list)
GNC-DENOM-AUTO GNC-RND-ROUND) GNC-DENOM-AUTO GNC-RND-ROUND))
You can fix it if you cheat and convert the terms to doubles, and the
result back to a gnc-numeric.
I updated bug 612467 with this info, though I was useing version 2.4.0 I
guess the advanced portfolio code hasn't changed in a while.
Is this an underlying weakness in the gnc-numeric library? I wonder what
other places overflows are going unoticed.
Thanks for a great project,
Clif
More information about the gnucash-user
mailing list