/* Serialize a floating-point number in such a way that it can be scanned back by Lua. Use hexadecimal format for "common" numbers (to preserve precision); inf, -inf, and NaN are handled separately. (NaN cannot be expressed as a numeral, so we write '(0/0)' for it.)  */
static int quotefloat(lua_State *L, char *buff, lua_Number n)
/* Serialize a floating-point number in such a way that it can be scanned back by Lua. Use hexadecimal format for "common" numbers (to preserve precision); inf, -inf, and NaN are handled separately. (NaN cannot be expressed as a numeral, so we write '(0/0)' for it.)  */
static int quotefloat(lua_State *L, char *buff, lua_Number n)
{
    int  nb = lua_number2strx(L, buff, MAX_ITEM,
                                 "%" LUA_NUMBER_FRMLEN "a", n);
    if (memchr(buff, '.', nb) == NULL) {
      char point = lua_getlocaledecpoint();
      char *ppoint = (char *)memchr(buff, point, nb);
      if (ppoint) *ppoint = '.';
    }
    return nb;
  }
  return l_sprintf(buff, MAX_ITEM, "%s", s);
}