ack/lang/basic/lib/conversion.c

39 lines
416 B
C
Raw Normal View History

1994-06-24 11:31:16 +00:00
/* $Id$ */
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;
if( f<-32768 || f>32767) error(4);
if(f<0)
r= f-0.5;
else r= f+0.5;
return(r);
}
2016-12-12 20:15:25 +00:00
double _trunc(double f)
1984-11-29 14:22:02 +00:00
{
long d;
d=f;
f=d;
return( f );
}
2016-12-12 20:15:25 +00:00
double _fcint(double f)
1984-11-29 14:22:02 +00:00
{
long r;
if(f<0){
r= -f;
r= -r -1;
}else r= f;
f=r;
return(f);
}
2016-12-12 20:15:25 +00:00
int _fix(double f)
1984-11-29 14:22:02 +00:00
{
int r;
if( f<-32768.0 || f>32767.0) error(4);
r= _sgn(f) * _fcint((f>0.0? f : -f));
return(r);
}