CSharp examples for System:Bit
Returns how many bits are necessary to hold a certain number
using System.Text; using System.Linq; using System.Collections.Generic; using System;/* w ww. ja va2 s. co m*/ public class Main{ /// <summary> /// Returns how many bits are necessary to hold a certain number /// </summary> public static int BitsToHoldUInt(uint value) { int bits = 1; while ((value >>= 1) != 0) bits++; return bits; } }