lua-users home
lua-l archive

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


Here's a simple, ANSI-c fix

#ifndef _control87
#define _control87 _controlfp
#endif

/*
** luai_hashnum is a macro to hash a lua_Number value into an integer.
** The hash must be deterministic and give reasonable values for
** both small and large values (outside the range of integers).
*/
#define luai_hashnum(i,n) { int e, cw;  \
   cw = _control87(0, 0);\
   _control87(_PC_53, MCW_PC); \
   n = l_mathop(frexp)(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP);  \
   lua_number2int(i, n); i += e; \
   _control87(cw, MCW_EM);}