Re: Functions for coversion strings to intergers
Konstantin Aladyshev
What I meant is there is no difference in the result between the "0"
toggle quoted message
Show quoted text
string, and "hhh" string. Both would get translated to the number zero. And something like "16dfgdf" would get translated to 16. But I think I've found a C library function, that is the base for these StrDecimalToUintnS/StrDecimalToUint64S functions. It is `strtol`. And in the case of strtol it is a caller responsibility to check for all the possible error cases via comparing first and second argument: https://stackoverflow.com/questions/26080829/detecting-strtol-failure/26083517 ``` CHAR16* End; UINTN MyVar; RETURN_STATUS Status = StrDecimalToUintnS(Argv[Index], &End, &MyVar); if ((Status != RETURN_SUCCESS) || (Argv[Index] == End) || (*End != 0)) Print(L"Error! incorrect number\n"); } ``` So I think that clears my question. Sorry to bother you. Best regards, Konstantin Aladyshev On Wed, Jul 21, 2021 at 9:23 PM Andrew Fish <afish@...> wrote:
|
|