Lua bit.checkbit() function, returns if a specified bit is on/off.

This commit is contained in:
pasky1382 2014-01-19 17:42:21 +00:00
parent df89951325
commit 1a0e98b7ad
1 changed files with 9 additions and 1 deletions

View File

@ -1,4 +1,5 @@
namespace BizHawk.Client.Common
using System;
namespace BizHawk.Client.Common
{
public class BitLuaLibrary : LuaLibraryBase
{
@ -17,6 +18,7 @@
"rol",
"ror",
"rshift",
"check",
};
}
}
@ -62,5 +64,11 @@
{
return (uint)(LuaInt(val) >> LuaInt(amt));
}
public static bool bit_check(object num, object pos)
{
var value = Convert.ToInt64(LuaLong(num));
return (value & (1 << (int)(LuaInt(pos)))) != 0;
}
}
}