lua-users home
lua-l archive

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


/*
** hash for lua_Numbers
*/
/* Taken from Lua 5.1 to avoid frexp() */
/* http://www.cse.yorku.ca/~oz/hash.html */
#define numints	cast_int(sizeof(lua_Number)/sizeof(int))
static Node *hashnum (const Table *t, lua_Number n) {
  unsigned int* a = (unsigned int*)(&n);
  unsigned int h = 5381;
  int i;

  if (luai_numeq(n, 0))  /* avoid problems with -0 */
    return gnode(t, 0);

  for (i = 0; i < numints; i++) h = h * 33 + a[i];
  return hashmod(t, h);
}



--
View this message in context: http://lua.2524044.n2.nabble.com/BUG-lua-5-2-luai-hashnum-bug-with-threads-tp7659173p7659213.html
Sent from the Lua-l mailing list archive at Nabble.com.