Luna/luna/NumberParsing.h
2022-11-19 12:30:36 +01:00

41 lines
594 B
C

#pragma once
#include <CType.h>
#include <Types.h>
inline usize _atou(const char** str)
{
usize val = 0;
while (_isdigit(**str))
{
val = (10 * val) + (**str - '0');
(*str)++;
}
return val;
}
inline isize _atos(const char** str)
{
bool neg = false;
isize val = 0;
switch (**str)
{
case '-':
neg = true;
(*str)++;
break;
case '+': (*str)++; break;
default: break;
}
while (_isdigit(**str))
{
val = (10 * val) + (**str - '0');
(*str)++;
}
return neg ? -val : val;
}