gnc-numeric overflow and bugs 603426, 612467, 587875

clif at eugeneweb.com clif at eugeneweb.com
Fri Jan 14 15:59:02 EST 2011


Does anyone know where the documentation for the guile versions of the 
gnc-numeric functions is? I found this:

http://www.koders.com/scheme/fidFDF661F909F92995282879C0C953A034134BA7FC.aspx?s="Derek"

but it only covers a scant few functions. There are the C code 
versions here:

http://svn.gnucash.org/docs/head/group__Numeric.html

but it's noted that there are differences between the c and guile 
versions.

I don't have much experiance with list/scheme rational numbers. Does 
anyone know what the customary way of handleing or preventing an overflow 
is? What is the function and syntax (in guile) to check for an overflow?

 	Thanks,
 	Clif

On Thu, 13 Jan 2011 clif at eugeneweb.com wrote:

> 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