2018-06-23 22:35:51 +00:00
|
|
|
#include "lib.h"
|
1984-11-29 14:22:02 +00:00
|
|
|
|
2016-12-12 20:15:25 +00:00
|
|
|
int _cint(double f)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
int r;
|
2016-12-12 20:16:32 +00:00
|
|
|
if (f < -32768 || f > 32767)
|
|
|
|
error(4);
|
|
|
|
if (f < 0)
|
|
|
|
r = f - 0.5;
|
|
|
|
else
|
|
|
|
r = f + 0.5;
|
|
|
|
return (r);
|
1984-11-29 14:22:02 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 20:15:25 +00:00
|
|
|
double _trunc(double f)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
long d;
|
2016-12-12 20:16:32 +00:00
|
|
|
d = f;
|
|
|
|
f = d;
|
|
|
|
return (f);
|
1984-11-29 14:22:02 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 20:15:25 +00:00
|
|
|
double _fcint(double f)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
long r;
|
2016-12-12 20:16:32 +00:00
|
|
|
if (f < 0)
|
|
|
|
{
|
|
|
|
r = -f;
|
|
|
|
r = -r - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
r = f;
|
|
|
|
f = r;
|
|
|
|
return (f);
|
1984-11-29 14:22:02 +00:00
|
|
|
}
|
2016-12-12 20:15:25 +00:00
|
|
|
int _fix(double f)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
2016-12-12 20:16:32 +00:00
|
|
|
if (f < -32768.0 || f > 32767.0)
|
|
|
|
error(4);
|
|
|
|
r = _sgn(f) * _fcint((f > 0.0 ? f : -f));
|
|
|
|
return (r);
|
1984-11-29 14:22:02 +00:00
|
|
|
}
|