diff options
Diffstat (limited to 'lobject.c')
-rw-r--r-- | lobject.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 1.94 2002/12/04 17:38:31 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 1.95 2003/01/27 13:00:43 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -30,6 +30,20 @@ | |||
30 | const TObject luaO_nilobject = {LUA_TNIL, {NULL}}; | 30 | const TObject luaO_nilobject = {LUA_TNIL, {NULL}}; |
31 | 31 | ||
32 | 32 | ||
33 | /* | ||
34 | ** converts an integer to a "floating point byte", represented as | ||
35 | ** (mmmmmxxx), where the real value is (xxx) * 2^(mmmmm) | ||
36 | */ | ||
37 | int luaO_int2fb (unsigned int x) { | ||
38 | int m = 0; /* mantissa */ | ||
39 | while (x >= (1<<3)) { | ||
40 | x = (x+1) >> 1; | ||
41 | m++; | ||
42 | } | ||
43 | return (m << 3) | cast(int, x); | ||
44 | } | ||
45 | |||
46 | |||
33 | int luaO_log2 (unsigned int x) { | 47 | int luaO_log2 (unsigned int x) { |
34 | static const lu_byte log_8[255] = { | 48 | static const lu_byte log_8[255] = { |
35 | 0, | 49 | 0, |