1 /* benum.f -- translated by f2c (version 19980913).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
8 /* Table of constant values */
9
10 static integer c__1 = 1;
11
12 /* $Procedure BENUM ( Be a number? ) */
benum_(char * string,ftnlen string_len)13 logical benum_(char *string, ftnlen string_len)
14 {
15 /* System generated locals */
16 logical ret_val;
17
18 /* Builtin functions */
19 integer i_len(char *, ftnlen);
20
21 /* Local variables */
22 extern integer cpos_(char *, char *, integer *, ftnlen, ftnlen);
23 extern logical bedec_(char *, ftnlen);
24 integer d__, e, f, l;
25 extern logical beint_(char *, ftnlen);
26
27 /* $ Abstract */
28
29 /* Determine whether a string represents a number. */
30
31 /* $ Disclaimer */
32
33 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
34 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
35 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
36 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
37 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
38 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
39 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
40 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
41 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
42 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
43
44 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
45 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
46 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
47 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
48 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
49 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
50
51 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
52 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
53 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
54 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
55
56 /* $ Required_Reading */
57
58 /* WORDS */
59
60 /* $ Keywords */
61
62 /* ALPHANUMERIC */
63 /* NUMBERS */
64 /* SCANNING */
65 /* UTILITY */
66
67 /* $ Declarations */
68 /* $ Brief_I/O */
69
70 /* Variable I/O Description */
71 /* -------- --- -------------------------------------------------- */
72 /* STRING I Character string. */
73
74 /* The function returns TRUE if the string is a number. */
75 /* Otherwise, it returns FALSE. */
76
77 /* $ Detailed_Input */
78
79 /* STRING is any string. */
80
81 /* $ Detailed_Output */
82
83 /* If the input string contains a number (as defined in */
84 /* $Particulars below) the function returns TRUE. Otherwise, */
85 /* the function returns FALSE. */
86
87 /* $ Parameters */
88
89 /* None. */
90
91 /* $ Exceptions */
92
93 /* Error free. */
94
95 /* $ Files */
96
97 /* None. */
98
99 /* $ Particulars */
100
101 /* A number may be either of the following: */
102
103 /* 1) A decimal number (as defined by function BEDEC). */
104
105 /* 2) A decimal number followed by an exponent character */
106 /* ('E', 'e', 'D', or 'd') and an integer (as defined */
107 /* by function BEINT). */
108
109 /* $ Examples */
110
111 /* Four classes of numbers recognized by the various BE functions. */
112
113 /* UNS unsigned integer */
114 /* INT integer (includes INT) */
115 /* DEC decimal number (includes UNS, INT) */
116 /* NUM number (includes UNS, INT, NUM) */
117
118 /* The following table illustrates the differences between */
119 /* the classes. (Any number of leading and trailing blanks */
120 /* are acceptable.) */
121
122 /* String Accepted by */
123 /* ------------------ ------------------ */
124 /* 0 UNS, INT, DEC, NUM */
125 /* 21 */
126 /* 21994217453648 */
127
128 /* +0 INT, DEC, NUM */
129 /* -13 */
130 /* +21946 */
131
132 /* 1.23 DEC, NUM */
133 /* 12. */
134 /* .17 */
135 /* +4.1 */
136 /* -.25 */
137
138 /* 2.3e17 NUM */
139 /* 17.D-13275849 */
140 /* -.194265E+0004 */
141
142 /* Note that the functions don't take the magnitudes of the numbers */
143 /* into account. They may accept numbers that cannot be represented */
144 /* in Fortran variables. (For example, '2.19E999999999999' probably */
145 /* exceeds the maximum floating point number on any machine, but */
146 /* is perfectly acceptable to BENUM.) */
147
148 /* The following strings are not accepted by any of the functions. */
149
150 /* String Reason */
151 /* --------------- ---------------------------------------- */
152 /* 3/4 No implied operations (rational numbers) */
153 /* 37+14 No explicit operations */
154 /* E12 Must have mantissa */
155 /* 217,346.91 No commas */
156 /* 3.14 159 264 No embedded spaces */
157 /* PI No special numbers */
158 /* FIVE No textual numbers */
159 /* CXIV No roman numerals */
160
161 /* $ Restrictions */
162
163 /* None. */
164
165 /* $ Literature_References */
166
167 /* None. */
168
169 /* $ Author_and_Institution */
170
171 /* W.L. Taber (JPL) */
172
173 /* $ Version */
174
175 /* - SPICELIB Version 1.0.0, 01-DEC-1995 (WLT) */
176
177 /* -& */
178 /* $ Index_Entries */
179
180 /* determine if a string is a number */
181
182 /* -& */
183
184 /* SPICELIB functions */
185
186
187 /* Local Variables */
188
189
190 /* Determine whether or not there is an exponent character in the */
191 /* string. */
192
193 l = i_len(string, string_len);
194 e = cpos_(string, "EeDd", &c__1, string_len, (ftnlen)4);
195 d__ = e - 1;
196 f = e + 1;
197 if (e == 0) {
198
199 /* There is no exponent character, this is a number if it */
200 /* is a decimal number. */
201
202 ret_val = bedec_(string, string_len);
203 } else if (e == 1 || e == l) {
204 ret_val = FALSE_;
205 } else if (*(unsigned char *)&string[d__ - 1] == ' ' || *(unsigned char *)
206 &string[f - 1] == ' ') {
207 ret_val = FALSE_;
208 } else {
209 ret_val = bedec_(string, d__) && beint_(string + (f - 1), l - (f - 1))
210 ;
211 }
212 return ret_val;
213 } /* benum_ */
214
215