Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
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
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 40... Line 70...
40
 * Initial revision
70
 * Initial revision
41
 *
71
 *
42
***********************************************************************/
72
***********************************************************************/
43
#ifndef flpttypekey
73
#ifndef flpttypekey
44
#define flpttypekey 1
74
#define flpttypekey 1
45
 
-
 
46
 
-
 
47
 
75
 
48
#include <limits.h>
76
#include <limits.h>
49
 
77
 
50
#include "fbase.h"
78
#include "fbase.h"
51
 
-
 
52
 
79
 
53
 
80
 
54
#if FBASE == 10
81
#if FBASE == 10
55
 
82
 
56
/* FBASE 10 is obsolete */
83
/* FBASE 10 is obsolete */
57
 
84
 
58
# define MANT_SIZE 40
85
#define MANT_SIZE 40
59
 
86
 
60
#define Fdig unsigned char
87
#define Fdig unsigned char
61
 
88
 
62
# define FNUM_SIZE 65		/* max size required by flt2str */
89
#define FNUM_SIZE 65		/* max size required by flt2str */
63
/* MANT_SIZE + 1(sign) + 1(point) + 2(E+sign) + log(MAX_LONG) + 1(null) */
90
/* MANT_SIZE + 1(sign) + 1(point) + 2(E+sign) + log(MAX_LONG) + 1(null) */
64
 
91
 
65
#define E_MIN	(-1000000)	/* (LONG_MIN/10) doesnt work on 80386 cc 
92
#define E_MIN	(-1000000)	/* (LONG_MIN/10) doesnt work on 80386 cc
66
				*/
93
				*/
67
#define E_MAX	(LONG_MAX/10)
94
#define E_MAX	(LONG_MAX / 10)
68
 
-
 
69
/* Function status values:   */
-
 
70
# define OKAY		0
-
 
71
# define EXP2BIG	(-1)
-
 
72
# define SYNTAX		(-2)
-
 
73
# define DIVBY0		(-3)
-
 
74
 
-
 
75
/* Rounding types:   */
-
 
76
# define R2ZERO	0
-
 
77
# define R2PINF	1
-
 
78
# define R2NINF	2
-
 
79
# define R2NEAR	3
-
 
80
 
-
 
81
typedef struct _flt {
-
 
82
  Fdig  mant[MANT_SIZE];
-
 
83
				/* mantissa digit values [0-9] (NOT '0' to
-
 
84
				   '9') */
-
 
85
  /* point is between 1st and 2nd digits */
-
 
86
  int   sign;			/* -1: negative; +1: positive; 0: value is
-
 
87
				   zero */
-
 
88
  int  exp;			/* signed exponent; in range E_MIN..E_MAX 
-
 
89
				*/
-
 
90
}                   flt;	/* floating point representation */
-
 
91
 
-
 
92
 
-
 
93
#else
-
 
94
 
95
 
-
 
96
/* Function status values:   */
-
 
97
#define OKAY		0
-
 
98
#define EXP2BIG	(-1)
-
 
99
#define SYNTAX		(-2)
-
 
100
#define DIVBY0		(-3)
-
 
101
 
-
 
102
/* Rounding types:   */
-
 
103
#define R2ZERO	0
-
 
104
#define R2PINF	1
-
 
105
#define R2NINF	2
-
 
106
#define R2NEAR	3
-
 
107
 
95
/* all installers should use this definition */
108
/* floating point representation */
-
 
109
typedef struct _flt {
-
 
110
  Fdig mant[MANT_SIZE]; /* mantissa digit values [0-9] (NOT '0' to '9') */
-
 
111
  /* point is between 1st and 2nd digits */
-
 
112
  int sign;		/* -1: negative; +1: positive; 0: value is zero */
-
 
113
  int exp;		/* signed exponent; in range E_MIN..E_MAX */
-
 
114
} flt;
-
 
115
 
-
 
116
#else
96
 
117
 
-
 
118
/* all installers should use this definition */
-
 
119
 
-
 
120
/* MANT_SIZE is the number of mantissa array elements */
97
#ifndef MANT_SIZE
121
#ifndef MANT_SIZE
98
#define MANT_SIZE 8
122
#define MANT_SIZE 8
99
#endif
123
#endif
100
 
124
 
101
	/* MANT_SIZE is the number of mantissa array elements */
-
 
102
 
125
 
103
#define Fdig unsigned short
126
#define Fdig unsigned short
-
 
127
/* FBITS is the number of bits in one array element */
104
#define FBITS 16
128
#define FBITS 16
105
	/* FBITS is the number of bits in one array element */
-
 
106
 
129
 
107
#define E_MIN	(-16384)
130
#define E_MIN	(-16384)
108
#define E_MAX	(LONG_MAX/FBASE)
131
#define E_MAX	(LONG_MAX / FBASE)
109
 
132
 
110
/* Function status values:   */
133
/* Function status values:   */
111
# define OKAY		0
134
#define OKAY		0
112
# define EXP2BIG	(-1)
135
#define EXP2BIG	(-1)
113
# define SYNTAX		(-2)
136
#define SYNTAX		(-2)
114
# define DIVBY0		(-3)
137
#define DIVBY0		(-3)
115
 
138
 
116
/* Rounding types:   */
139
/* Rounding types:   */
117
# define R2ZERO	3
140
#define R2ZERO	3
118
# define R2PINF	2
141
#define R2PINF	2
119
# define R2NINF	1
142
#define R2NINF	1
120
# define R2NEAR	0
143
#define R2NEAR	0
121
 
144
 
122
typedef struct _flt {
145
typedef struct _flt {
123
  Fdig  mant[MANT_SIZE];
146
  Fdig mant[MANT_SIZE];
124
  /* point is between 1st and 2nd digits */
147
  /* point is between 1st and 2nd digits */
125
  int   sign;			/* -1: negative; +1: positive; 0: value is
148
  int sign;		/* -1: negative; +1: positive; 0: value is zero */
126
				   zero */
-
 
127
  int  exp;			/* signed exponent; in range E_MIN..E_MAX 
149
  int exp;		/* signed exponent; in range E_MIN..E_MAX */
128
				*/
-
 
129
}                   flt;	/* floating point representation */
150
} flt;	/* floating point representation */
130
 
151
 
131
 
152
 
132
	/* type for result of conversion of reals to ints */
153
/* type for result of conversion of reals to ints */
133
typedef struct r2l_t {
154
typedef struct r2l_t {
134
	int i1; /* least significant */
155
	int i1; /* least significant */
135
	int i2;
156
	int i2;
136
	int i3;
157
	int i3;
137
	int i4;	/* most significant */
158
	int i4;	/* most significant */
138
} r2l;
159
} r2l;
139
 
160
 
140
 
-
 
141
#endif
161
#endif
-
 
162
 
142
typedef struct flt64_t {
163
typedef struct flt64_t {
143
  int big;		/* more significant 32 bits */
164
  int big;		/* more significant 32 bits */
144
  unsigned int small;	/* less significant 32 bits */
165
  unsigned int small;	/* less significant 32 bits */
145
} flt64;
166
} flt64;
146
	/* used to convert flpt number which are integers into a
167
/* used to convert flpt number which are integers into a 64 bit
147
	   64 bit representation */
168
 * representation */
148
 
169
 
149
 
-
 
150
#endif
170
#endif /* flpttypekey */