Hi Eric,
> I needed gcc's clz to determine the most significant bit of a
> number
This new module is redundant w.r.t. the 'integer_length',
'integer_length_l', 'integer_length_ll' modules that are in gnulib
already since last year:
For x != 0:
count_leading_zeros (x) = sizeof x * CHAR_BIT - int
On 08/11/2012 01:45 AM, Jim Meyering wrote:
> Eric Blake wrote:
>> I needed gcc's clz to determine the most significant bit of a
>> number (useful for things like truncating to a power of 2),
>> and was surprised it is not a standardized function
> Did you consider using a variant of the following
On 08/11/2012 04:23 AM, Ondřej Bílka wrote:
>>
>> Did you consider using a variant of the following?
>> It looks like it would be more efficient.
The fallback code is only for non-gcc compilation in the first place,
but yes, the de Bruijn table lookup does seem nicer; I'll switch over to
using it.
On 08/10/2012 10:37 PM, Ben Pfaff wrote:
> Eric Blake writes:
>
>> +/* Expand the code which computes the number of leading zeros of the local
>> + variable 'x' of type TYPE (an unsigned integer type) and returns it
>> + from the current function. */
>> +#if 0 && __GNUC__ > 3 || (__GNUC__ ==
On Sat, Aug 11, 2012 at 09:45:16AM +0200, Jim Meyering wrote:
> Eric Blake wrote:
> > I needed gcc's clz to determine the most significant bit of a
> > number (useful for things like truncating to a power of 2),
> > and was surprised it is not a standardized function (the
> > opposite direction of
Eric Blake wrote:
> I needed gcc's clz to determine the most significant bit of a
> number (useful for things like truncating to a power of 2),
> and was surprised it is not a standardized function (the
> opposite direction of finding the least significant bit is
...
> +/* Expand the code which com
Eric Blake writes:
> +/* Expand the code which computes the number of leading zeros of the local
> + variable 'x' of type TYPE (an unsigned integer type) and returns it
> + from the current function. */
> +#if 0 && __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
Do you really want "0
I needed gcc's clz to determine the most significant bit of a
number (useful for things like truncating to a power of 2),
and was surprised it is not a standardized function (the
opposite direction of finding the least significant bit is
given by ffs). This borrows heavily from the design of the
c