numparam, change np_trunc() and np_round() return type to double
This commit is contained in:
parent
c1bd74f982
commit
da6790e68d
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue