Cosmos/source/Tests/MathTest/Lost/BitUtils.cs
LostTheBlack_cp ad77460ba8 [+] push and pop instructions passed tests.
[*] ModRM, Rex & SIB code is refactored slightly.
2008-04-09 09:22:12 +00:00

29 lines
552 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Lost
{
public static class BitUtils
{
public static int BitIndex(this int value)
{
for (int i = 0; i < 32; i++)
if (value == 1 << i) return i;
throw new ArgumentException("this");
}
}
public static class IntUtils
{
public static bool FitsInByte(this int value)
{
return ((byte)value) == value;
}
public static bool FitsInByte(this long value)
{
return ((byte)value) == value;
}
}
}