…or ceil(Int, log(2, x)) if you want the number of bits required to represent x as an unsigned integer.
It really depends on what you mean by “the number of bits in a number” :P // T On Tuesday, October 6, 2015 at 5:03:03 PM UTC+2, Steven G. Johnson wrote: > > On Tuesday, October 6, 2015 at 10:59:04 AM UTC-4, Scott Jones wrote: >> >> I couldn't find anything yet - is there a recommended / fastest way to >> get the number of bits in a number (I really only need it for unsigned >> values). >> Thanks >> > > sizeof(number)*8 if you want all the bits (though you'd need to define a > separate method for BigInt), or count_ones(number) if you want the 1 bits. >
