5 void const_parse_number(struct const_value
*restrict cv
, const char *restrict str
)
7 const char *restrict p
= str
;
8 long double place_value
, exponent
;
12 // octal or hexadecimal
14 if (tolower(*p
) == 'x'){
17 while (isdigit(*p
) || (tolower(*p
) >= 'a' && tolower(*p
) <= 'f')){
19 cv
->v
.i
= (cv
->v
.i
<< 4) | (*p
- '0');
21 cv
->v
.i
= (cv
->v
.i
<< 4) | ((tolower(*p
) - 'a') + 10);
28 while (*p
>= '0' && *p
<= '7'){
29 cv
->v
.i
= (cv
->v
.i
<< 3) | (*p
- 0);
33 } else if (*p
>= '0' && *p
<= 9){
35 while (*p
>= '0' && *p
<= '9'){
36 cv
->v
.i
= (cv
->v
.i
* 10) + (*p
- '0');
42 cv
->type
= CBT_LONGDOUBLE
;
45 while (*p
>= '0' && *p
<= '9'){
46 cv
->v
.ld
= (*p
- '0') * place_value
;
51 if (tolower(*p
) == 'e'){
53 if (cv
->type
!= CBT_LONGDOUBLE
){
55 cv
->type
= CBT_LONGDOUBLE
;
59 while (*p
>= '0' && *p
<= '9'){
60 exponent
= (exponent
* 10.0) + (*p
- '0');
63 cv
->v
.ld
*= powl(10, exponent
);