1988-04-07 11:40:46 +00:00
|
|
|
/*
|
|
|
|
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Header$ */
|
|
|
|
|
1988-04-07 10:57:49 +00:00
|
|
|
/********************************************************/
|
|
|
|
/*
|
|
|
|
NORMALIZE an EXTENDED FORMAT NUMBER
|
|
|
|
*/
|
|
|
|
/********************************************************/
|
|
|
|
|
|
|
|
#include "FP_shift.h"
|
|
|
|
#include "FP_types.h"
|
|
|
|
|
|
|
|
nrm_ext(e1)
|
|
|
|
EXTEND *e1;
|
|
|
|
{
|
|
|
|
/* we assume that the mantissa != 0 */
|
|
|
|
/* if it is then just return */
|
|
|
|
/* to let it be a problem elsewhere */
|
|
|
|
/* THAT IS, The exponent is not set to */
|
|
|
|
/* zero. If we don't test here an */
|
|
|
|
/* infinite loop is generated when */
|
|
|
|
/* mantissa is zero */
|
|
|
|
|
1988-08-04 11:16:20 +00:00
|
|
|
if ((e1->m1 | e1->m2) == 0L)
|
1988-04-07 10:57:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* if top word is zero mov low word */
|
|
|
|
/* to top word, adjust exponent value */
|
1988-08-04 11:16:20 +00:00
|
|
|
if (e1->m1 == 0L) {
|
|
|
|
e1->m1 = e1->m2;
|
|
|
|
e1->m2 = 0L;
|
1988-04-07 10:57:49 +00:00
|
|
|
e1->exp -= 32;
|
|
|
|
}
|
1988-08-04 11:16:20 +00:00
|
|
|
if ((e1->m1 & NORMBIT) == 0) {
|
|
|
|
unsigned long l = ((unsigned long)NORMBIT >> 1);
|
|
|
|
int cnt = -1;
|
|
|
|
|
|
|
|
while (! (l & e1->m1)) {
|
|
|
|
l >>= 1;
|
|
|
|
cnt--;
|
1988-04-07 10:57:49 +00:00
|
|
|
}
|
1988-08-04 11:16:20 +00:00
|
|
|
e1->exp += cnt;
|
|
|
|
b64_sft(&(e1->m1), cnt);
|
1988-04-07 10:57:49 +00:00
|
|
|
}
|
|
|
|
}
|