Cosmos/source/Lost/Assembler/BitUtils.cs
LostTheBlack_cp 3060b02e0c AMD64 assembler:
[-] some unnecessary overloads
[+] overloaded operators in order to allow defining memory operands easily
[+] overloaded automatic conversions to allow operands
[+] Labels support
[+] code generator based on F# started
2008-05-09 11:29:38 +00:00

37 lines
745 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;
}
public static bool FitsInSByte(this long value)
{
return ((sbyte)value) == value;
}
public static bool FitsInSByte(this int value)
{
return ((sbyte)value) == value;
}
}
}