61 if(c >=
'0' && c <=
'9')
63 else if(c >=
'A' && c <=
'F')
65 else if(c >=
'a' && c <=
'f')
68 return((ret >= radix) ? -1 : ret);
98 num =
strtol(str, &endptr, base);
136 strtol(
const char *nptr,
char **endptr,
int base)
142 while(*nptr ==
' ' || *nptr ==
'\t')
150 else if(*nptr ==
'+' )
171 *endptr = (
char *) nptr;
183 strtoll(
const char *nptr,
char **endptr,
int base)
185 unsigned long long num;
189 while(*nptr ==
' ' || *nptr ==
'\t')
197 else if(*nptr ==
'+' )
218 *endptr = (
char *) nptr;
223 #ifdef __SIZEOF_INT128__ 232 strto128(
const char *nptr,
char **endptr,
int base)
238 while(*nptr ==
' ' || *nptr ==
'\t')
246 else if(*nptr ==
'+' )
268 *endptr = (
char *) nptr;
313 iexp(
double num,
int exp)
368 exp10 = ((double) exp2) / (double) 3.321928095;
371 scale =
iexp((
double)10.0, exp10);
377 while(num >= (
double)10.0)
379 num /= (double) 10.0;
382 while(num < (
double) 1.0)
384 num *= (double) 10.0;
401 strtod(
const char *nptr,
char **endptr)
407 int digit, power,sign;
409 while(*nptr ==
' ' || *nptr ==
'\t' || *nptr ==
'\n')
417 else if(*nptr ==
'+')
428 digit = (*nptr -
'0');
429 num += (double) digit;
439 digit = (*nptr -
'0');
440 tmp = (double) digit;
449 if(*nptr ==
'E' || *nptr ==
'e')
452 sign = (*nptr ==
'-') ? -1 : 1;
453 if(sign == -1 || *nptr ==
'+')
459 digit = (*nptr -
'0');
460 power += (double) digit;
468 num *=
iexp(10.0, power);
472 *endptr = (
char *) nptr;
482 atof(
const char *str)
489 #endif // ifdef FLOATIO MEMSPACE int atodigit(int c, int radix)
Convert ASCII character to radix based digit , or -1.
Master include file for project Includes all project includes and defines here.
MEMSPACE double scale10(double num, int *exp)
MEMSPACE int mul10str(uint8_t *str, int size)
Fast multiply number of any size by 10.
MEMSPACE double atof(const char *str)
MEMSPACE double strtod(const char *nptr, char **endptr)
MEMSPACE long atol(const char *str)
Convert ASCII string to number in base 10.
Math IO functions, and verious conversion code with floating point support.
MEMSPACE long strtol(const char *nptr, char **endptr, int base)
Convert ASCII string to number in a given base.
MEMSPACE double iexp(double num, int exp)
MEMSPACE long long strtoll(const char *nptr, char **endptr, int base)
Convert ASCII string to number in a given base.
MEMSPACE int WEAK_ATR isdigit(int c)
test if a character is a digit
MEMSPACE int atoi(const char *str)
Convert ASCII string to number in base 10.
MEMSPACE long aton(char *str, int base)
Convert ASCII string to number in a given base.
MEMSPACE long atoh(const char *p)
Convert ASCII hex string to long integer.