fix errors for 32bit arch.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8523 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c18f0bd237
commit
ce94984b71
3 changed files with 60 additions and 71 deletions
|
|
@ -197,6 +197,7 @@ SWIG_AsVal_dec(ptrdiff_t)(SWIG_Object obj, ptrdiff_t *val)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment("SWIG_CanCastAsInteger","header",
|
||||
fragment=SWIG_AsVal_frag(double),
|
||||
fragment="<float.h>",
|
||||
|
|
@ -205,21 +206,25 @@ SWIGINTERNINLINE int
|
|||
SWIG_CanCastAsInteger(double *d, double min, double max) {
|
||||
double x = *d;
|
||||
if ((min <= x && x <= max)) {
|
||||
double fx = floor(x);
|
||||
double rd = ((x - fx) < 0.5) ? fx : ceil(x); /* simple rint */
|
||||
double fx = floor(x);
|
||||
double cx = ceil(x);
|
||||
double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
|
||||
if ((errno == EDOM) || (errno == ERANGE)) {
|
||||
errno = 0;
|
||||
} else {
|
||||
if (rd == x) {
|
||||
return 1;
|
||||
double summ, reps, diff;
|
||||
if (rd < x) {
|
||||
diff = x - rd;
|
||||
} else if (rd > x) {
|
||||
diff = rd - x;
|
||||
} else {
|
||||
double diff = rd - x;
|
||||
double summ = rd + x;
|
||||
double reps = diff/summ;
|
||||
if (fabs(reps) < 8*DBL_EPSILON) {
|
||||
*d = rd;
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
summ = rd + x;
|
||||
reps = diff/summ;
|
||||
if (reps < 8*DBL_EPSILON) {
|
||||
*d = rd;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue