Don't use fmod(), broken on vxWorks.

Use long rather than int for integer calculations.
This commit is contained in:
Andrew Johnson
2008-05-08 16:15:50 +00:00
parent e74e839ccd
commit 2a34e2e464
2 changed files with 20 additions and 18 deletions

View File

@@ -42,14 +42,12 @@ epicsShareFunc long
double stack[CALCPERFORM_STACK+1]; /* zero'th entry not used */
double *ptop; /* stack pointer */
double top; /* value from top of stack */
int itop; /* integer from top of stack */
char nargs;
long itop; /* integer from top of stack */
int nargs;
/* initialize */
ptop = stack;
if(*pinst == END_EXPRESSION) return -1;
/* RPN evaluation loop */
while (*pinst != END_EXPRESSION){
switch (*pinst){
@@ -132,8 +130,11 @@ epicsShareFunc long
break;
case MODULO:
top = *ptop--;
*ptop = fmod(*ptop, top);
itop = (long) *ptop--;
if (itop)
*ptop = (long) *ptop % itop;
else
*ptop = 0.0 / itop; /* NaN */
break;
case POWER:
@@ -276,33 +277,33 @@ epicsShareFunc long
break;
case BIT_OR:
itop = (int) *ptop--;
*ptop = (int) *ptop | itop;
itop = (long) *ptop--;
*ptop = (long) *ptop | itop;
break;
case BIT_AND:
itop = (int) *ptop--;
*ptop = (int) *ptop & itop;
itop = (long) *ptop--;
*ptop = (long) *ptop & itop;
break;
case BIT_EXCL_OR:
itop = (int) *ptop--;
*ptop = (int) *ptop ^ itop;
itop = (long) *ptop--;
*ptop = (long) *ptop ^ itop;
break;
case BIT_NOT:
itop = (int) *ptop;
itop = (long) *ptop;
*ptop = ~itop;
break;
case RIGHT_SHIFT:
itop = (int) *ptop--;
*ptop = (int) *ptop >> itop;
itop = (long) *ptop--;
*ptop = (long) *ptop >> itop;
break;
case LEFT_SHIFT:
itop = (int) *ptop--;
*ptop = (int) *ptop << itop;
itop = (long) *ptop--;
*ptop = (long) *ptop << itop;
break;
case NOT_EQ:

View File

@@ -200,7 +200,7 @@ MAIN(epicsCalcTest)
Inf /= NaN;
NaN /= NaN;
testPlan(532);
testPlan(533);
/* LITERAL_OPERAND elements */
testExpr(0);
@@ -467,6 +467,7 @@ MAIN(epicsCalcTest)
testExpr(7 % 4);
testExpr(-7 % 4);
testExpr(63 % 16 % 6)
testCalc("1 % 0", NaN);
testExpr(7 & 4);