#count significant bits
1 messages · Page 1 of 1 (latest)
what does "significant bits" mean to you
1 messages · Page 1 of 1 (latest)
fn significant_bits(x: anytype) @TypeOf(@clz(x))
{ const int_bits: @TypeOf(@clz(x)) =
@truncate(@typeInfo(@TypeOf(x)).Int.bits);
if (x >= 0) return int_bits - @clz(x);
return int_bits - @clz(~x) + 1; }
is there a better way to accomplish this?
what does "significant bits" mean to you