public static int UintSize(ulong val) { int bytes = 1; while ((val >>= 8) > 0) bytes++; return bytes; }