source: trunk/minix/lib/ack/float/cuf4.fc@ 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/ack/float/cuf4.fc,v 1.1 2005/10/10 15:27:42 beng Exp $ */
7
8/*
9 CONVERT INTEGER TO SINGLE (CUF n 4)
10
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.
15*/
16
17#include "FP_types.h"
18
19void
20cuf4(ss,src)
21int ss; /* source size */
22long src; /* largest possible integer to convert */
23{
24 EXTEND buf;
25 short *ipt;
26 SINGLE *result;
27 long i_src;
28
29 zrf_ext(&buf);
30 if (ss == sizeof(long)) {
31 buf.exp = 31;
32 i_src = src;
33 result = (SINGLE *) &src;
34 }
35 else {
36 ipt = (short *) &src;
37 i_src = (long) *ipt;
38 buf.exp = 15;
39 result = (SINGLE *) ((void *) &ss);
40 }
41 if (i_src == 0) {
42 *result = (SINGLE) 0L;
43 return;
44 }
45 /* ESTABLISHED THAT src != 0 */
46
47 /* adjust exponent field */
48 if (ss != sizeof(long))
49 i_src <<= 16;
50
51 /* move to mantissa field */
52 buf.m1 = i_src;
53
54 /* adjust mantissa field */
55 nrm_ext(&buf);
56 compact(&buf,result,4);
57}
Note: See TracBrowser for help on using the repository browser.