Uninitialized vector entry?
[minix3.git] / lib / float / cif8.c
blob1ab9798133216b4317aedf9052c2185f7071dcb4
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 */
6 /* $Header$ */
8 /*
9 CONVERT INTEGER TO FLOAT (CIF n 8)
11 THIS ROUTINE WORKS BY FILLING AN EXTENDED
12 WITH THE INTEGER VALUE IN EXTENDED FORMAT
13 AND USES COMPACT() TO PUT IT INTO THE PROPER
14 FLOATING POINT PRECISION.
17 #include "FP_types.h"
19 void
20 cif8(ss,src)
21 int ss; /* source size */
22 long src; /* largest possible integer to convert */
24 EXTEND buf;
25 DOUBLE *result; /* for return value */
26 short *ipt;
27 long i_src;
29 result = (DOUBLE *) ((void *) &ss); /* always */
30 zrf_ext(&buf);
31 if (ss == sizeof(long)) {
32 buf.exp = 31;
33 i_src = src;
35 else {
36 ipt = (short *) &src;
37 i_src = (long) *ipt;
38 buf.exp = 15;
40 if (i_src == 0) {
41 zrf8(result);
42 return;
44 /* ESTABLISHED THAT src != 0 */
45 /* adjust exponent field */
46 buf.sign = (i_src < 0) ? 0x8000 : 0;
47 /* clear sign bit of integer */
48 /* move to mantissa field */
49 buf.m1 = (i_src < 0) ? -i_src : i_src;
50 /* adjust mantissa field */
51 if (ss != sizeof(long))
52 buf.m1 <<= 16;
53 nrm_ext(&buf);
54 compact(&buf,&result->d[0],8);