FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
strw_convfrom_radlng.c
Go to the documentation of this file.
1
#include "
fb.h
"
2
3
FBCALL
long
long
fb_WstrRadix2Longint
(
const
FB_WCHAR
*src, ssize_t len,
int
radix )
4
{
5
long
long
v;
6
int
c;
7
8
v = 0;
9
10
switch
( radix )
11
{
12
/* hex */
13
case
16:
14
while
( --len >= 0 )
15
{
16
c = *src++;
17
if
( (c >= 97) && (c <= 102) )
18
c -= 87;
19
else
if
( (c >= 65) && (c <= 70) )
20
c -= 55;
21
else
if
( (c >= 48) && (c <= 57) )
22
c -= 48;
23
else
24
break
;
25
26
v = (v * 16) + c;
27
}
28
break
;
29
30
/* oct */
31
case
8:
32
while
( --len >= 0 ) {
33
c = *src++;
34
if
( (c >= 48) && (c <= 55) )
35
v = (v * 8) + (c - 48);
36
else
37
break
;
38
}
39
break
;
40
41
/* bin */
42
case
2:
43
while
( --len >= 0 ) {
44
c = *src++;
45
if
( (c >= 48) && (c <= 49) )
46
v = (v * 2) + (c - 48);
47
else
48
break
;
49
}
50
break
;
51
}
52
53
return
v;
54
}
rtlib
strw_convfrom_radlng.c
Generated on Thu Jan 23 2014 19:40:13 for FreeBASIC by
1.8.4