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

59 lines
1.6 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 "@(#)ftoffp.c 1.2 10/19/83"; */
/*
* Floating Point to FFP Floating Point Routine :
* FFP Standard Single Precision Representation Floating Point
*
* long
* fptoffp(f)
* float f;
*
* Rely's on the fact that a long and a float are both 32 bits.
*/
long
fptoffp(f) /* convert current machine float to ffp rep */
float f; /* unsigned input, guaranteed positive */
{
register int exp, count, sign;
long l;
if (f == 0.0)
return(0L);
if (f < 0.0) {
f = -f;
sign = 1;
}
else
sign = 0;
exp = 0L;
for( ; f >= 1.0; f = f / 2.0)
exp++;
for( ; f < 0.5; f = f * 2.0)
exp--;
f = f * 16777216.0; /* 2 ^ 24 */
l = f;
l <<= 8;
exp += 0x40;
l |= (exp & 0x7f);
if (sign)
l |= 0x80;
return(l);
}
 l |= 0x80;
return(l);
}
 l |= 0x80;
return(l);
}
 l |= 0x80;
return(l);
}