source: trunk/MagicSoft/slalib/flotin.c@ 10075

Last change on this file since 10075 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.8 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaFlotin ( char *string, int *nstrt, float *reslt, int *jflag )
4/*
5** - - - - - - - - - -
6** s l a F l o t i n
7** - - - - - - - - - -
8**
9** Convert free-format input into single precision floating point.
10**
11** Given:
12** *string char string containing field to be decoded
13** *nstrt int where to start decode (1st = 1)
14**
15** Returned:
16** *nstrt int advanced to next field
17** *reslt float result
18** *jflag int -1 = -OK, 0 = +OK, 1 = null field, 2 = error
19**
20** Called: slaDfltin
21**
22** Notes:
23**
24** 1 A tab character is interpreted as a space, and lower
25** case d,e are interpreted as upper case.
26**
27** 2 The basic format is #^.^@#^ where # means + or -,
28** ^ means a decimal subfield and @ means d or e.
29**
30** 3 Spaces:
31** Leading spaces are ignored.
32** Embedded spaces are allowed only after # and d or e,
33** and after . where the first ^ is absent.
34** Trailing spaces are ignored; the first signifies
35** end of decoding and subsequent ones are skipped.
36**
37** 4 Field separators:
38** Any character other than +,-,0-9,.,d,e or space may be
39** used to end a field. Comma is recognized by slaFlotin
40** as a special case; it is skipped, leaving the
41** pointer on the next character. See 12, below.
42**
43** 5 Both signs are optional. The default is +.
44**
45** 6 The mantissa defaults to 1.
46**
47** 7 The exponent defaults to e0.
48**
49** 8 The decimal subfields may be of any length.
50**
51** 9 The decimal point is optional for whole numbers.
52**
53** 10 A null field is one that does not begin with
54** +,-,0-9,.,d or e, or consists entirely of spaces.
55** If the field is null, jflag is set to 1 and reslt
56** is left untouched.
57**
58** 11 nstrt = 1 for the first character in the string.
59**
60** 12 On return from slaFlotin, nstrt is set ready for the next
61** decode - following trailing blanks and (if used) the
62** comma separator. If a separator other than comma is
63** being used, nstrt must be incremented before the next
64** call to slaFlotin.
65**
66** 13 Errors (jflag=2) occur when:
67** a) A +, -, d or e is left unsatisfied.
68** b) The decimal point is present without at least
69** one decimal subfield.
70** c) An exponent more than 100 has been presented.
71**
72** 14 When an error has been detected, nstrt is left
73** pointing to the character following the last
74** one used before the error came to light. This
75** may be after the point at which a more sophisticated
76** program could have detected the error. For example,
77** slaFlotin does not detect that '1e999' is unacceptable
78** until the whole field has been read.
79**
80** 15 Certain highly unlikely combinations of mantissa &
81** exponent can cause arithmetic faults during the
82** decode, in some cases despite the fact that they
83** together could be construed as a valid number.
84**
85** 16 Decoding is left to right, one pass.
86**
87** 17 End of field may occur in either of two ways:
88** a) As dictated by the string length.
89** b) Detected during the decode.
90** (b overrides a.)
91**
92** 18 See also slaDfltin and slaIntin.
93**
94** Last revision: 23 November 1995
95**
96** Copyright P.T.Wallace. All rights reserved.
97*/
98{
99 double dreslt;
100
101/* Call the double precision version */
102 slaDfltin ( string, nstrt, &dreslt, jflag );
103 if ( *jflag <= 0 ) *reslt = (float) dreslt;
104}
Note: See TracBrowser for help on using the repository browser.