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

78 lines
2.0 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 "@(#) _ieeetof - dec 29, 1982"; */
/*
* IEEE Floating Point Representation to Internal Representation :
* IEEE Standard Single Precision Representation Floating Point
*
* float
* _ieeetof(lf)
* long lf;
*
* Largest positive number is 3.4 * 10^33 and the smallest positive
* number is 1.2 * 10^-38.
* Rely's on the fact that a long and a float are both 32 bits.
*/
#define BIAS 127L
float
_ieeetof(lf)
long lf;
{
register long exp;
register int count, fsign;
float f;
if (lf == 0L)
return(0.0);
if (lf < 0L) {
fsign = 1;
lf =& 0x7fffffff; /* mask MSB (sign) */
}
else
fsign = 0;
exp = (lf >> 23) & 0xff; /* biased ieee exponent */
exp =- BIAS;
lf =& 0x7fffff; /* 23 bits of fraction */
f = lf;
if (lf != 0) /* don't need to do floating point test !!! */
f = f / 8388608.0; /* 2 ^ 23 */
f = f + 1.0; /* ieee fraction : 1.F */
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);
}