numparam, change np_trunc() and np_round() return type to double

This commit is contained in:
rlar 2014-05-24 12:54:01 +02:00
parent c1bd74f982
commit da6790e68d
3 changed files with 9 additions and 9 deletions

View File

@ -47,8 +47,8 @@ char rc(void);
int freadstr(FILE *f, SPICE_DSTRINGPTR dstr_p); int freadstr(FILE *f, SPICE_DSTRINGPTR dstr_p);
long np_round(double d); // sjb to avoid clash with round() in math.h double np_round(double d); // sjb to avoid clash with round() in math.h
long np_trunc(double x); // sjb to avoid clash with trunc() in math.h double np_trunc(double x); // sjb to avoid clash with trunc() in math.h
double absf(double x); /* abs */ double absf(double x); /* abs */
long absi(long i); long absi(long i);

View File

@ -599,18 +599,18 @@ spos_(char *sub, const char *s)
} }
long double
np_round(double r) np_round(double r)
{ {
return (long) floor(r + 0.5); return floor(r + 0.5);
} }
long double
np_trunc(double r) np_trunc(double r)
{ {
if (r >= 0.0) if (r >= 0.0)
return (long) floor(r); return floor(r);
else else
return (long) ceil(r); return ceil(r);
} }

View File

@ -979,11 +979,11 @@ operate(char op, double x, double y)
x = z; x = z;
break; break;
case '%': /* % */ case '%': /* % */
t = (double)(np_trunc(x / y)); t = np_trunc(x / y);
x = x - y * t; x = x - y * t;
break; break;
case '\\': /* / */ case '\\': /* / */
x = (double)(np_trunc(fabs(x / y))); x = np_trunc(fabs(x / y));
break; break;
} }