public static int Log2(int val) { ConverterStruct a = new ConverterStruct { asFloat = val }; return(((a.asInt >> 23) + 1) & 0x1F); }
public static int Base2Ceil(int val) { ConverterStruct a = new ConverterStruct { asFloat = val }; int result = 1 << (((a.asInt >> 23) + 1) & 0x1F); if (result != val) { return(result * 2); } return(result); }
public static int Log2Ceil(int val) { ConverterStruct a = new ConverterStruct { asFloat = val }; int log = (((a.asInt >> 23) + 1) & 0x1F); if ((1 << log) != val) { return(log + 1); } return(log); }