Files
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

65 lines
1.3 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
Copyright 1982
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
*/
/* char *version "@(#)ftol.c 1.2 10/19/83"; */
/*
* Floating Point Float to Long Routine :
* Front End to IEEE Floating Point Package.
*
* long
* fpftol(fparg)
* double fparg;
*
* Return : Fixed Point representation of Floating Point Number
*/
#define BIAS 127L
long
fpftol(f)
long f;
{
register long l;
register int exp, sign;
l = (f & 0x7f800000) >> 23;
exp = l - BIAS;
if (f == 0L || exp < 0) /* underflow or 0 */
return(0L);
sign = (f < 0L);
if (exp > 31) /* overflow */
return( (sign) ? 0x80000000 : 0x7fffffff);
exp =- 23;
l = (f & 0x7fffff) | 0x800000; /* 1.F */
for( ; exp < 0 ; exp++)
l =>> 1;
for( ; exp > 0; exp--)
l =<< 1;
if (sign)
l = -l;
return(l);
}
for( ; exp > 0; exp--)
l =<< 1;
if (sign)
l = -l;
return(l);
}
for( ; exp > 0; exp--)
l =<< 1;
if (sign)
l = -l;
return(l);
}
for( ; exp > 0; exp--)
l =<< 1;
if (sign)
l = -l;
return(l);
}