Function calcLimbLen [src]
Returns the number of limbs needed to store scalar, which must be a
primitive integer value.
Note: A comptime-known upper bound of this value that may be used
instead if scalar is not already comptime-known is
calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).int.bits)
Prototype
pub fn calcLimbLen(scalar: anytype) usize
Source
pub fn calcLimbLen(scalar: anytype) usize {
if (scalar == 0) {
return 1;
}
const w_value = @abs(scalar);
return @as(usize, @intCast(@divFloor(@as(Limb, @intCast(math.log2(w_value))), limb_bits) + 1));
}