IntBitLength
IntBitLength
Description
Get the number of significant bits in an integer.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to inspect |
Usage example (from documentation)
u64 bits = IntBitLength(&value);Returns
Number of significant bits, or 0 for zero.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:165:
static bool int_is_one(Int *value) {
ValidateInt(value);
return IntBitLength(value) == 1 && BitVecGet(INT_BITS(value), 0);
}- In
Int.c:284:
}
u64 IntBitLength(Int *value) {
return int_significant_bits(value);
}- In
Int.c:289:
u64 IntByteLength(Int *value) {
u64 bits = IntBitLength(value);
return bits == 0 ? 0 : (bits + 7) / 8;
}- In
Int.c:300:
}
return IntBitLength(value) - 1;
}- In
Int.c:316:
bool IntIsZero(Int *value) {
return IntBitLength(value) == 0;
}- In
Int.c:334:
bool IntFitsU64(Int *value) {
ValidateInt(value);
return IntBitLength(value) <= 64;
}- In
Int.c:340:
ValidateInt(value);
return !IntIsZero(value) && IntBitLength(value) == IntTrailingZeroCount(value) + 1;
}- In
Int.c:598:
ValidateInt(rhs);
u64 lhs_bits = IntBitLength(lhs);
u64 rhs_bits = IntBitLength(rhs);- In
Int.c:599:
u64 lhs_bits = IntBitLength(lhs);
u64 rhs_bits = IntBitLength(rhs);
if (lhs_bits < rhs_bits) {- In
Int.c:623:
ValidateInt(lhs);
if (IntBitLength(lhs) > 64) {
return 1;
}- In
Int.c:652:
ValidateInt(value);
u64 bits = IntBitLength(value);
if (positions == 0) {- In
Int.c:677:
ValidateInt(value);
u64 bits = IntBitLength(value);
if (positions == 0) {- In
Int.c:701:
ValidateInt(b);
u64 a_bits = IntBitLength(a);
u64 b_bits = IntBitLength(b);
u64 max_bits = MAX2(a_bits, b_bits);- In
Int.c:702:
u64 a_bits = IntBitLength(a);
u64 b_bits = IntBitLength(b);
u64 max_bits = MAX2(a_bits, b_bits);
Int temp = int_init_with_capacity(max_bits + 1);- In
Int.c:765:
}
u64 a_bits = IntBitLength(a);
u64 b_bits = IntBitLength(b);
Int temp = int_init_with_capacity(a_bits);- In
Int.c:766:
u64 a_bits = IntBitLength(a);
u64 b_bits = IntBitLength(b);
Int temp = int_init_with_capacity(a_bits);
bool borrow = false;- In
Int.c:821:
ValidateInt(b);
u64 b_bits = IntBitLength(b);
Int acc = IntInit();- In
Int.c:944:
if (IntCompare(&normalized_dividend, &normalized_divisor) >= 0) {
u64 dividend_bits = IntBitLength(&normalized_dividend);
u64 divisor_bits = IntBitLength(&normalized_divisor);- In
Int.c:945:
if (IntCompare(&normalized_dividend, &normalized_divisor) >= 0) {
u64 dividend_bits = IntBitLength(&normalized_dividend);
u64 divisor_bits = IntBitLength(&normalized_divisor);
q = int_init_with_capacity(dividend_bits - divisor_bits + 1);- In
Int.c:962:
r = next;
if (IntBitLength(&q) < bit + 1) {
BitVecResize(INT_BITS(&q), bit + 1);
}- In
Int.c:1192:
}
u64 bits = IntBitLength(value);
u64 high_shift = bits / degree;
Int low = IntInit();- In
Int.c:1298:
ValidateInt(value);
if (IntIsZero(value) || IntBitLength(value) == 1) {
return true;
}- In
Int.Convert.c:42:
Str text = IntToBinary(&value);
bool result = IntBitLength(&value) == 4;
result = result && (IntToU64(&value) == 13);
result = result && (strcmp(text.data, "1101") == 0); Str text = IntToBinary(&zero);
bool result = IntBitLength(&zero) == 0;
result = result && IntIsZero(&zero);
result = result && (IntToU64(&zero) == 0);
bool result = IntToU64(&value) == 163;
result = result && (IntBitLength(&value) == 8);
IntDeinit(&value);- In
Int.Access.c:19:
bool test_int_bit_length(void) {
WriteFmt("Testing IntBitLength\n");
Int value = IntFromBinary("00101000");- In
Int.Access.c:23:
Int value = IntFromBinary("00101000");
bool result = IntBitLength(&value) == 6;
IntDeinit(&value);- In
Int.Math.c:69:
bool result = IntToU64(&value) == 48;
result = result && (IntBitLength(&value) == 6);
IntDeinit(&value);- In
Int.Math.c:83:
bool result = IntToU64(&value) == 3;
result = result && (IntBitLength(&value) == 2);
IntDeinit(&value);- In
Int.Type.c:17:
bool result = IntIsZero(&value);
result = result && (IntBitLength(&value) == 0);
IntDeinit(&value);- In
Int.Type.c:31:
bool result = IntIsZero(&value);
result = result && (IntBitLength(&value) == 0);
IntDeinit(&value);
Last updated on