Pristine Ack-5.5
[Ack-5.5.git] / modules / src / flt_arith / flt_nrm.c
1 /*
2   (c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands.
3   See the copyright notice in the ACK home directory, in the file "Copyright".
4 */
5
6 /* $Id: flt_nrm.c,v 1.7 1994/06/24 11:16:04 ceriel Exp $ */
7
8 #include "flt_misc.h"
9
10 void
11 flt_nrm(e)
12         register flt_arith *e;
13 {
14         if ((e->m1 | e->m2) == 0L) {
15                 e->flt_exp = 0;
16                 e->flt_sign = 0;
17                 return;
18         }
19
20         /* if top word is zero mov low word     */
21         /* to top word, adjust exponent value   */
22         if (e->m1 == 0L)        {
23                 e->m1 = e->m2;
24                 e->m2 = 0L;
25                 e->flt_exp -= 32;
26         }
27         if ((e->m1 & 0x80000000) == 0) {
28                 long l = 0x40000000;
29                 int cnt = -1;
30
31                 while (! (l & e->m1)) {
32                         l >>= 1;
33                         cnt--;
34                 }
35                 e->flt_exp += cnt;
36                 flt_b64_sft(&(e->flt_mantissa), cnt);
37         }
38 }