I'm starting this thread to move discussions of the fixed point implementation away from the patch thread. I did some more analysis and found that the main culprit in overflow is warm starting (disabled/enabled by the checkbox in the testbed). I don't know what warm starting is, I'm guessing it has to do with the initial conditions for some iterative solver. It seems to be important to keeping stacks of things together.
The other interesting thing is that the testbed overflows about 20 times before the first line of main is executed. I'm guessing these overflows are in object constructors that call multiply, but finding those is tough.
BTW, the code I'm using to track where overflow is occuring is in Fixed.h (works in LInux, I doubt it would work in Windows):
#if 0
// more acurate, using long long
inline Fixed Fixed::operator *(const Fixed a) const { return Fixed(RAW, (int)\
( ((long long)g * (long long)a.g ) >> BP)); }
#elif 1
#include <execinfo.h>
#include <signal.h>
#include <exception>
inline Fixed Fixed::operator *(const Fixed a) const {
long long x = ((long long)g * (long long)a.g );
if(x > 0x7fffffffffffLL || x < -0x7fffffffffffLL) {
printf("overflow");
void *array[2];
int nSize = backtrace(array, 2);
char **symbols = backtrace_symbols(array, nSize);
for(int i=0; i<nSize; i++) {
printf(" %s", symbols[i]);
}
printf("\n");
}
return Fixed(RAW, (int)(x>>BP));
}
#else
The other interesting thing is that the testbed overflows about 20 times before the first line of main is executed. I'm guessing these overflows are in object constructors that call multiply, but finding those is tough.
BTW, the code I'm using to track where overflow is occuring is in Fixed.h (works in LInux, I doubt it would work in Windows):
#if 0
// more acurate, using long long
inline Fixed Fixed::operator *(const Fixed a) const { return Fixed(RAW, (int)\
( ((long long)g * (long long)a.g ) >> BP)); }
#elif 1
#include <execinfo.h>
#include <signal.h>
#include <exception>
inline Fixed Fixed::operator *(const Fixed a) const {
long long x = ((long long)g * (long long)a.g );
if(x > 0x7fffffffffffLL || x < -0x7fffffffffffLL) {
printf("overflow");
void *array[2];
int nSize = backtrace(array, 2);
char **symbols = backtrace_symbols(array, nSize);
for(int i=0; i<nSize; i++) {
printf(" %s", symbols[i]);
}
printf("\n");
}
return Fixed(RAW, (int)(x>>BP));
}
#else