Rev | Line | |
---|
[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/fphook/cuf8.fc,v 1.1 2005/10/10 15:27:43 beng Exp $ */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
| 9 | CONVERT INTEGER TO FLOAT (CUF n 8)
|
---|
| 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 |
|
---|
| 19 | void
|
---|
| 20 | cuf8(ss,src)
|
---|
| 21 | int ss; /* source size */
|
---|
| 22 | long src; /* largest possible integer to convert */
|
---|
| 23 | {
|
---|
| 24 | EXTEND buf;
|
---|
| 25 | short *ipt;
|
---|
| 26 | long i_src;
|
---|
| 27 |
|
---|
| 28 | zrf_ext(&buf);
|
---|
| 29 | if (ss == sizeof(long)) {
|
---|
| 30 | buf.exp = 31;
|
---|
| 31 | i_src = src;
|
---|
| 32 | }
|
---|
| 33 | else {
|
---|
| 34 | ipt = (short *) &src;
|
---|
| 35 | i_src = (long) *ipt;
|
---|
| 36 | buf.exp = 15;
|
---|
| 37 | }
|
---|
| 38 | if (i_src == 0) {
|
---|
| 39 | zrf8((DOUBLE *)((void *)&ss));
|
---|
| 40 | return;
|
---|
| 41 | }
|
---|
| 42 | /* ESTABLISHED THAT src != 0 */
|
---|
| 43 |
|
---|
| 44 | /* adjust exponent field */
|
---|
| 45 | if (ss != sizeof(long))
|
---|
| 46 | i_src <<= 16;
|
---|
| 47 |
|
---|
| 48 | /* move to mantissa field */
|
---|
| 49 | buf.m1 = i_src;
|
---|
| 50 |
|
---|
| 51 | /* adjust mantissa field */
|
---|
| 52 | nrm_ext(&buf);
|
---|
| 53 | compact(&buf,(unsigned long *) (void *)&ss,8);
|
---|
| 54 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.