lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Is there a chance a official support for hexadecimal numbers to be added for lua 5.1 release? I'll be very happy because now I patch it and it'll be very nice for me to not
deviate from official sources.
regards,
Todor

On Thu, 09 Feb 2006 17:11:19 +0200, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

What about this?

   char *endptr;
   *result = lua_str2number(s, &endptr);
   if (endptr == s) return 0;  /* conversion failed */
+  if (*endptr == 'x') *result = strtoul(s, &endptr, 16);
   if (*endptr == '\0') return 1;  /* most common case */
   while (isspace(cast(unsigned char, *endptr))) endptr++;
   if (*endptr != '\0') return 0;  /* invalid trailing characters? */

-- Roberto