source: trunk/minix/lib/float/nrm_ext.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.1 KB
RevLine 
[9]1/*
2 (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 See the copyright notice in the ACK home directory, in the file "Copyright".
4*/
5
6/* $Header: /cvsup/minix/src/lib/float/nrm_ext.c,v 1.1.1.1 2005/04/21 14:56:11 beng Exp $ */
7
8/********************************************************/
9/*
10 NORMALIZE an EXTENDED FORMAT NUMBER
11*/
12/********************************************************/
13
14#include "FP_shift.h"
15#include "FP_types.h"
16
17void
18nrm_ext(e1)
19EXTEND *e1;
20{
21 /* we assume that the mantissa != 0 */
22 /* if it is then just return */
23 /* to let it be a problem elsewhere */
24 /* THAT IS, The exponent is not set to */
25 /* zero. If we don't test here an */
26 /* infinite loop is generated when */
27 /* mantissa is zero */
28
29 if ((e1->m1 | e1->m2) == 0L)
30 return;
31
32 /* if top word is zero mov low word */
33 /* to top word, adjust exponent value */
34 if (e1->m1 == 0L) {
35 e1->m1 = e1->m2;
36 e1->m2 = 0L;
37 e1->exp -= 32;
38 }
39 if ((e1->m1 & NORMBIT) == 0) {
40 unsigned long l = ((unsigned long)NORMBIT >> 1);
41 int cnt = -1;
42
43 while (! (l & e1->m1)) {
44 l >>= 1;
45 cnt--;
46 }
47 e1->exp += cnt;
48 b64_sft(&(e1->mantissa), cnt);
49 }
50}
Note: See TracBrowser for help on using the repository browser.