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

70 lines
1.4 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 "@(#)ffptof.c 1.2 10/19/83"; */
/*
* FFP Floating Point Representation to Internal Representation :
* FFP Standard Single Precision Representation Floating Point
*
* float
* ffptof(lf)
* long lf;
*
* Largest positive number is 3.4 * 10^18 and the smallest positive
* number is 1.2 * 10^-20.
* Rely's on the fact that a long and a float are both 32 bits.
*/
float
ffptof(lf)
long lf;
{
register int exp, count, fsign;
float f;
if (lf == 0L)
return(0.0);
fsign = (lf & 0x80);
exp = (lf & 0x7f) - 0x40;
lf = (lf>>8) & 0xffffff; /* 24 bits of fraction */
f = lf;
f = f / 16777216.0; /* 2 ^ 24 */
while (exp < 0) { /* negative exp : 2^-? */
f = f / 2.0;
exp++;
}
while (exp > 0) { /* positive exp : 2^+? */
f = f * 2.0;
exp--;
}
if (fsign)
f = -f;
return(f);
}

exp--;
}
if (fsign)
f = -f;
return(f);
}

exp--;
}
if (fsign)
f = -f;
return(f);
}

exp--;
}
if (fsign)
f = -f;
return(f);
}