FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
file_input_float.c
Go to the documentation of this file.
1
/* input function for float's and double's */
2
3
#include "
fb.h
"
4
5
FBCALL
int
fb_InputSingle
(
float
*dst )
6
{
7
char
buffer
[
FB_INPUT_MAXNUMERICLEN
+1];
8
ssize_t len;
9
int
isfp;
10
11
len =
fb_FileInputNextToken
( buffer,
FB_INPUT_MAXNUMERICLEN
,
FB_FALSE
, &isfp );
12
13
if
( isfp ==
FALSE
)
14
{
15
if
( len <=
FB_INPUT_MAXINTLEN
)
16
*dst = (float)
fb_hStr2Int
( buffer, len );
17
else
if
( len <=
FB_INPUT_MAXLONGLEN
)
18
*dst = (float)
fb_hStr2Longint
( buffer, len );
19
else
20
{
21
if
( buffer[0] ==
'&'
)
22
*dst = (float)
fb_hStr2Longint
( buffer, len );
23
else
24
*dst = strtof( buffer,
NULL
);
25
}
26
}
27
else
28
*dst = strtof( buffer,
NULL
);
29
30
return
fb_ErrorSetNum
(
FB_RTERROR_OK
);
31
}
32
33
FBCALL
int
fb_InputDouble
(
double
*dst )
34
{
35
char
buffer
[
FB_INPUT_MAXNUMERICLEN
+1];
36
ssize_t len;
37
int
isfp;
38
39
len =
fb_FileInputNextToken
( buffer,
FB_INPUT_MAXNUMERICLEN
,
FB_FALSE
, &isfp );
40
41
if
( isfp ==
FALSE
)
42
{
43
if
( len <=
FB_INPUT_MAXINTLEN
)
44
*dst = (double)
fb_hStr2Int
( buffer, len );
45
else
if
( len <=
FB_INPUT_MAXLONGLEN
)
46
*dst = (double)
fb_hStr2Longint
( buffer, len );
47
else
48
{
49
if
( buffer[0] ==
'&'
)
50
*dst = (double)
fb_hStr2Longint
( buffer, len );
51
else
52
*dst = strtod( buffer,
NULL
);
53
}
54
}
55
else
56
*dst = strtod( buffer,
NULL
);
57
58
return
fb_ErrorSetNum
(
FB_RTERROR_OK
);
59
}
rtlib
file_input_float.c
Generated on Thu Jan 23 2014 19:40:11 for FreeBASIC by
1.8.4