mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
Core: Atoi, Atoi64
This commit is contained in:
parent
5e5819ad3c
commit
0cea273540
4 changed files with 35 additions and 0 deletions
|
|
@ -157,5 +157,15 @@ CONSOLE_APP_MAIN
|
|||
DDUMP(CParser("123456123").ReadNumber64(8));
|
||||
DDUMP(CParser("123456123").ReadNumber64(16));
|
||||
|
||||
DDUMP(Atoi(""));
|
||||
DDUMP(Atoi("x"));
|
||||
DDUMP(Atoi("123"));
|
||||
DDUMP(Atoi("-123"));
|
||||
|
||||
DDUMP(Atoi64(""));
|
||||
DDUMP(Atoi64("x"));
|
||||
DDUMP(Atoi64("123"));
|
||||
DDUMP(Atoi64("-123"));
|
||||
|
||||
CheckLogEtalon();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,3 +56,11 @@ e = (1,1): number is too big
|
|||
CParser("123456123").ReadNumber64() = 123456123
|
||||
CParser("123456123").ReadNumber64(8) = 21912659
|
||||
CParser("123456123").ReadNumber64(16) = 591749411
|
||||
Atoi("") = 0
|
||||
Atoi("x") = 0
|
||||
Atoi("123") = 123
|
||||
Atoi("-123") = -123
|
||||
Atoi64("") = 0
|
||||
Atoi64("x") = 0
|
||||
Atoi64("123") = 123
|
||||
Atoi64("-123") = -123
|
||||
|
|
|
|||
|
|
@ -133,6 +133,13 @@ int ScanInt(const char *ptr)
|
|||
return ScanInt<char, byte, uint32, int, 10>(x, ptr, overflow) && !overflow ? x : Null;
|
||||
}
|
||||
|
||||
int Atoi(const char *ptr)
|
||||
{
|
||||
int x;
|
||||
bool overflow = false;
|
||||
return ScanInt<char, byte, uint32, int, 10>(x, ptr, overflow) && !overflow ? x : 0;
|
||||
}
|
||||
|
||||
int64 ScanInt64(const char *ptr, const char **endptr)
|
||||
{
|
||||
int64 x;
|
||||
|
|
@ -150,6 +157,13 @@ int64 ScanInt64(const char *ptr)
|
|||
return ScanInt<char, byte, uint64, int64, 10>(x, ptr, overflow) && !overflow ? x : Null;
|
||||
}
|
||||
|
||||
int64 Atoi64(const char *ptr)
|
||||
{
|
||||
int64 x;
|
||||
bool overflow = false;
|
||||
return ScanInt<char, byte, uint64, int64, 10>(x, ptr, overflow) && !overflow ? x : 0;
|
||||
}
|
||||
|
||||
Value StrIntValue(const char *s)
|
||||
{
|
||||
if(s && *s) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ int64 ScanInt64(const char *ptr, const char **endptr, int radix);
|
|||
int64 ScanInt64(const char *ptr, const char **endptr);
|
||||
int64 ScanInt64(const char *ptr);
|
||||
|
||||
int Atoi(const char *ptr);
|
||||
int64 Atoi64(const char *ptr);
|
||||
|
||||
double ScanDouble(const char *ptr, const char **endptr, bool accept_comma);
|
||||
double ScanDouble(const wchar *ptr, const wchar **endptr, bool accept_comma);
|
||||
double ScanDouble(const char *ptr, const char **endptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue