2 |
7u83 |
1 |
/*
|
7 |
7u83 |
2 |
* Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
*
|
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
|
6 |
* modification, are permitted provided that the following conditions are met:
|
|
|
7 |
*
|
|
|
8 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
9 |
* this list of conditions and the following disclaimer.
|
|
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
11 |
* this list of conditions and the following disclaimer in the documentation
|
|
|
12 |
* and/or other materials provided with the distribution.
|
|
|
13 |
* 3. Neither the name of The TenDRA Project nor the names of its contributors
|
|
|
14 |
* may be used to endorse or promote products derived from this software
|
|
|
15 |
* without specific, prior written permission.
|
|
|
16 |
*
|
|
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
|
18 |
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
19 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
|
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
22 |
* EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
23 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
24 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
25 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
26 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
27 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
28 |
*
|
|
|
29 |
* $Id$
|
|
|
30 |
*/
|
|
|
31 |
/*
|
2 |
7u83 |
32 |
Crown Copyright (c) 1997
|
7 |
7u83 |
33 |
|
2 |
7u83 |
34 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
35 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
36 |
acting through the Defence Evaluation and Research Agency
|
|
|
37 |
(DERA). It is made available to Recipients with a
|
|
|
38 |
royalty-free licence for its use, reproduction, transfer
|
|
|
39 |
to other parties and amendment for any purpose not excluding
|
|
|
40 |
product development provided that any such use et cetera
|
|
|
41 |
shall be deemed to be acceptance of the following conditions:-
|
7 |
7u83 |
42 |
|
2 |
7u83 |
43 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
44 |
reproduced upon any copies or amended versions of it;
|
7 |
7u83 |
45 |
|
2 |
7u83 |
46 |
(2) Any amended version of it shall be clearly marked to
|
|
|
47 |
show both the nature of and the organisation responsible
|
|
|
48 |
for the relevant amendment or amendments;
|
7 |
7u83 |
49 |
|
2 |
7u83 |
50 |
(3) Its onward transfer from a recipient to another
|
|
|
51 |
party shall be deemed to be that party's acceptance of
|
|
|
52 |
these conditions;
|
7 |
7u83 |
53 |
|
2 |
7u83 |
54 |
(4) DERA gives no warranty or assurance as to its
|
|
|
55 |
quality or suitability for any purpose and DERA accepts
|
|
|
56 |
no liability whatsoever in relation to any use to which
|
|
|
57 |
it may be put.
|
|
|
58 |
*/
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
/**********************************************************************
|
|
|
62 |
$Author: release $
|
|
|
63 |
$Date: 1998/01/17 15:55:47 $
|
|
|
64 |
$Revision: 1.1.1.1 $
|
|
|
65 |
$Log: flpttypes.h,v $
|
|
|
66 |
* Revision 1.1.1.1 1998/01/17 15:55:47 release
|
|
|
67 |
* First version to be checked into rolling release.
|
|
|
68 |
*
|
|
|
69 |
* Revision 1.1 1995/04/06 10:44:05 currie
|
|
|
70 |
* Initial revision
|
|
|
71 |
*
|
|
|
72 |
***********************************************************************/
|
|
|
73 |
#ifndef flpttypekey
|
|
|
74 |
#define flpttypekey 1
|
|
|
75 |
|
|
|
76 |
#include <limits.h>
|
|
|
77 |
|
|
|
78 |
#include "fbase.h"
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
#if FBASE == 10
|
|
|
82 |
|
|
|
83 |
/* FBASE 10 is obsolete */
|
|
|
84 |
|
7 |
7u83 |
85 |
#define MANT_SIZE 40
|
2 |
7u83 |
86 |
|
|
|
87 |
#define Fdig unsigned char
|
|
|
88 |
|
7 |
7u83 |
89 |
#define FNUM_SIZE 65 /* max size required by flt2str */
|
2 |
7u83 |
90 |
/* MANT_SIZE + 1(sign) + 1(point) + 2(E+sign) + log(MAX_LONG) + 1(null) */
|
|
|
91 |
|
7 |
7u83 |
92 |
#define E_MIN (-1000000) /* (LONG_MIN/10) doesnt work on 80386 cc
|
2 |
7u83 |
93 |
*/
|
7 |
7u83 |
94 |
#define E_MAX (LONG_MAX / 10)
|
2 |
7u83 |
95 |
|
|
|
96 |
/* Function status values: */
|
7 |
7u83 |
97 |
#define OKAY 0
|
|
|
98 |
#define EXP2BIG (-1)
|
|
|
99 |
#define SYNTAX (-2)
|
|
|
100 |
#define DIVBY0 (-3)
|
2 |
7u83 |
101 |
|
|
|
102 |
/* Rounding types: */
|
7 |
7u83 |
103 |
#define R2ZERO 0
|
|
|
104 |
#define R2PINF 1
|
|
|
105 |
#define R2NINF 2
|
|
|
106 |
#define R2NEAR 3
|
2 |
7u83 |
107 |
|
7 |
7u83 |
108 |
/* floating point representation */
|
2 |
7u83 |
109 |
typedef struct _flt {
|
7 |
7u83 |
110 |
Fdig mant[MANT_SIZE]; /* mantissa digit values [0-9] (NOT '0' to '9') */
|
2 |
7u83 |
111 |
/* point is between 1st and 2nd digits */
|
7 |
7u83 |
112 |
int sign; /* -1: negative; +1: positive; 0: value is zero */
|
|
|
113 |
int exp; /* signed exponent; in range E_MIN..E_MAX */
|
|
|
114 |
} flt;
|
2 |
7u83 |
115 |
|
|
|
116 |
#else
|
|
|
117 |
|
|
|
118 |
/* all installers should use this definition */
|
|
|
119 |
|
7 |
7u83 |
120 |
/* MANT_SIZE is the number of mantissa array elements */
|
2 |
7u83 |
121 |
#ifndef MANT_SIZE
|
|
|
122 |
#define MANT_SIZE 8
|
|
|
123 |
#endif
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
#define Fdig unsigned short
|
7 |
7u83 |
127 |
/* FBITS is the number of bits in one array element */
|
2 |
7u83 |
128 |
#define FBITS 16
|
|
|
129 |
|
|
|
130 |
#define E_MIN (-16384)
|
7 |
7u83 |
131 |
#define E_MAX (LONG_MAX / FBASE)
|
2 |
7u83 |
132 |
|
|
|
133 |
/* Function status values: */
|
7 |
7u83 |
134 |
#define OKAY 0
|
|
|
135 |
#define EXP2BIG (-1)
|
|
|
136 |
#define SYNTAX (-2)
|
|
|
137 |
#define DIVBY0 (-3)
|
2 |
7u83 |
138 |
|
|
|
139 |
/* Rounding types: */
|
7 |
7u83 |
140 |
#define R2ZERO 3
|
|
|
141 |
#define R2PINF 2
|
|
|
142 |
#define R2NINF 1
|
|
|
143 |
#define R2NEAR 0
|
2 |
7u83 |
144 |
|
|
|
145 |
typedef struct _flt {
|
7 |
7u83 |
146 |
Fdig mant[MANT_SIZE];
|
2 |
7u83 |
147 |
/* point is between 1st and 2nd digits */
|
7 |
7u83 |
148 |
int sign; /* -1: negative; +1: positive; 0: value is zero */
|
|
|
149 |
int exp; /* signed exponent; in range E_MIN..E_MAX */
|
|
|
150 |
} flt; /* floating point representation */
|
2 |
7u83 |
151 |
|
|
|
152 |
|
7 |
7u83 |
153 |
/* type for result of conversion of reals to ints */
|
2 |
7u83 |
154 |
typedef struct r2l_t {
|
|
|
155 |
int i1; /* least significant */
|
|
|
156 |
int i2;
|
|
|
157 |
int i3;
|
|
|
158 |
int i4; /* most significant */
|
|
|
159 |
} r2l;
|
|
|
160 |
|
7 |
7u83 |
161 |
#endif
|
2 |
7u83 |
162 |
|
|
|
163 |
typedef struct flt64_t {
|
|
|
164 |
int big; /* more significant 32 bits */
|
|
|
165 |
unsigned int small; /* less significant 32 bits */
|
|
|
166 |
} flt64;
|
7 |
7u83 |
167 |
/* used to convert flpt number which are integers into a 64 bit
|
|
|
168 |
* representation */
|
2 |
7u83 |
169 |
|
7 |
7u83 |
170 |
#endif /* flpttypekey */
|