float CEIL_FLOOR(float x, int n)
{
float y, res;
long l;
int1 s;
s = 0;
y = x;
if (x < 0)
{
s = 1;
y = -y;
}
if (y <= 32768.0)
res = (float)(long)y;
else if (y < 10000000.0)
{
l = (long)(y/32768.0);
y = 32768.0*(y/32768.0 - (float)l);
res = 32768.0*(float)l;
res += (float)(long)y;
}
else
res = y;
y = y - (float)(long)y;
if (s)
res = -res;
if (y != 0)
{
if (s == 1 && n == 0)
res -= 1.0;
if (s == 0 && n == 1)
res += 1.0;
}
if (x == 0)
res = 0;
return (res);
}
////////////////////////////////////////////////////////////////////////////
// float floor(float x)
////////////////////////////////////////////////////////////////////////////
// Description : rounds down the number x.
// Date : N/A
//
{
return CEIL_FLOOR(x, 0);
}
////////////////////////////////////////////////////////////////////////////
// float ceil(float x)
////////////////////////////////////////////////////////////////////////////
// Description : rounds up the number x.
// Date : N/A
//
{
return CEIL_FLOOR(x, 1);
}