IntIsZero
Description
Test whether the integer equals zero.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to inspect. |
Success
Returns true when the integer represents zero.
Failure
Returns false for any non-zero value.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:164:
static void sint_normalize(SignedInt *value) {
int_normalize(&value->magnitude);
if (IntIsZero(&value->magnitude)) {
value->negative = false;
}- In
Int.c:217:
SignedInt neg_b = sint_clone(b);
if (!IntIsZero(&neg_b.magnitude)) {
neg_b.negative = !neg_b.negative;
}- In
Int.c:406:
ValidateInt(value);
if (IntIsZero(value)) {
LOG_ERROR("log2 undefined for zero");
return false;- In
Int.c:438:
}
bool IntIsZero(const Int *value) {
return IntBitLength(value) == 0;
}- In
Int.c:463:
ValidateInt(value);
return !IntIsZero(value) && IntBitLength(value) == IntTrailingZeroCount(value) + 1;
}- In
Int.c:762:
}
if (IntIsZero(value)) {
return StrPushBackR(out, '0');
}- In
Int.c:767:
current = IntClone(value);
if (IntIsZero(¤t)) {
return false;
}- In
Int.c:801:
}
while (!IntIsZero(¤t)) {
u64 rem = 0;
bool last = false;- In
Int.c:814:
}
rem = IntToU64(&remainder);
last = IntIsZero("ient);
// A non-final chunk emits exactly chunk_digits digits (zero-padded for
- In
Int.c:1424:
ValidateInt(b);
if (IntIsZero(a) || IntIsZero(b)) {
IntClear(result);
return true;- In
Int.c:1614:
LOG_FATAL("quotient and remainder must be different objects");
}
if (IntIsZero(divisor)) {
LOG_ERROR("Division by zero");
return false;- In
Int.c:1753:
ValidateInt(divisor);
if (IntIsZero(divisor)) {
LOG_ERROR("Division by zero");
return false;- In
Int.c:1766:
return false;
}
if (!IntIsZero(&remainder)) {
IntDeinit("ient);
IntDeinit(&remainder);- In
Int.c:1945:
}
while (!IntIsZero(&y)) {
Int r = IntInit(IntAllocator(result));- In
Int.c:1969:
ValidateInt(b);
if (IntIsZero(a) || IntIsZero(b)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);- In
Int.c:2005:
}
if (IntIsZero(value)) {
Int zero_root = IntInit(IntAllocator(root));
Int zero_rem = IntInit(IntAllocator(remainder));- In
Int.c:2115:
Int next = IntInit(IntAllocator(root));
if (IntEQ(&mid, &one) || IntIsZero(&mid)) {
IntDeinit(&high);
high = IntInit(IntAllocator(root));- In
Int.c:2199:
return false;
}
result = IntIsZero(&remainder);
IntDeinit(&root);- In
Int.c:2209:
ValidateInt(value);
if (IntIsZero(value) || IntBitLength(value) == 1) {
return true;
}- In
Int.c:2229:
return false;
}
exact = IntIsZero(&remainder);
IntDeinit(&root);- In
Int.c:2250:
}
if (IntIsZero(n) || IntIsEven(n)) {
LOG_ERROR("n must be non-zero and odd");
return false;- In
Int.c:2265:
}
while (!IntIsZero(&aa)) {
while (IntIsEven(&aa)) {
u64 n_mod_8 = 0;- In
Int.c:2322:
ValidateInt(modulus);
if (IntIsZero(modulus)) {
LOG_ERROR("modulus is zero");
return false;- In
Int.c:2375:
ValidateInt(modulus);
if (IntIsZero(modulus)) {
LOG_ERROR("modulus is zero");
return false;- In
Int.c:2404:
return false;
}
if (IntIsZero(&diff)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);- In
Int.c:2430:
ValidateInt(modulus);
if (IntIsZero(modulus)) {
LOG_ERROR("modulus is zero");
return false;- In
Int.c:2475:
ValidateInt(modulus);
if (IntIsZero(modulus)) {
LOG_ERROR("modulus is zero");
return false;- In
Int.c:2511:
ValidateInt(modulus);
if (IntIsZero(modulus)) {
LOG_FATAL("modulus is zero");
}- In
Int.c:2565:
ValidateInt(modulus);
if (IntIsZero(modulus)) {
LOG_ERROR("modulus is zero");
return false;- In
Int.c:2584:
Int scratch = IntInit(IntAllocator(result));
while (!IntIsZero(&exp)) {
if (int_is_odd(&exp)) {
if (!IntModMul(&scratch, &acc, &base_mod, modulus)) {- In
Int.c:2603:
return false;
}
if (!IntIsZero(&exp)) {
if (!IntModMul(&scratch, &base_mod, &base_mod, modulus)) {
IntDeinit(&acc);- In
Int.c:2635:
ValidateInt(modulus);
if (IntIsZero(modulus)) {
LOG_ERROR("modulus is zero");
return false;- In
Int.c:2667:
}
while (!IntIsZero(&new_r)) {
Int q = IntInit(IntAllocator(result));
Int rem = IntInit(IntAllocator(result));- In
Int.c:2720:
return false;
}
if (t.negative && !IntIsZero(&mag_mod)) {
if (!int_sub(&positive, modulus, &mag_mod)) {
IntDeinit(&positive);- In
Int.c:2765:
ValidateInt(modulus);
if (IntIsZero(modulus)) {
LOG_ERROR("modulus is zero");
return false;- In
Int.c:2778:
}
if (IntIsZero(&a)) {
Int zero = IntInit(IntAllocator(result));
int_replace(result, &zero);- In
Float.c:259:
ValidateFloat(value);
if (IntIsZero(&value->significand)) {
value->negative = false;
value->exponent = 0;- In
Float.c:283:
if (int_try_from_u64(&ten, 10, alloc)) {
while (int_div_mod(&q, &r, &value->significand, &ten) && IntIsZero(&r)) {
Int tmp = value->significand;
value->significand = q;- In
Float.c:299:
bool FloatIsZero(const Float *value) {
ValidateFloat(value);
return IntIsZero(&value->significand);
}- In
Float.c:593:
}
result.negative = negative && !IntIsZero(&result.significand);
result.exponent = explicit_exp - fractional;- In
Type.c:252:
bool ok = FloatToInt(&result, &value);
bool right = ok && IntIsZero(&result);
IntDeinit(&result);- In
Type.c:23:
Int value = IntInit(&alloc.base);
bool result = IntIsZero(&value);
result = result && (IntBitLength(&value) == 0);- In
Type.c:40:
IntClear(&value);
bool result = IntIsZero(&value);
result = result && (IntBitLength(&value) == 0);- In
Math.c:291:
IntMul(&result_value, &a, &b);
bool result = IntIsZero(&result_value);
result = result && (IntToU64(&result_value) == 0);- In
Math.c:1568:
bool ok = IntMul(&product, &a, &zero);
bool result = ok && IntIsZero(&product);
result = result && (IntToU64(&product) == 0u);
result = result && (IntBitLength(&product) == 0u);- In
Math.c:1848:
bool result = IntLCM(&result_value, &a, &b);
result = result && IntIsZero(&result_value);
result = result && (IntCompare(&result_value, 0) == 0);- In
Math.c:3225:
bool result = ok;
result = result && (IntToU64("ient) == 123456789u);
result = result && IntIsZero(&remainder);
IntDeinit(÷nd);- In
Math.c:3252:
bool result = ok;
result = result && IntIsZero("ient);
result = result && (IntToU64(&remainder) == 42u);- In
Math.c:3708:
bool ok = IntMul(&r, &x, &y);
ok = ok && IntIsZero(&r);
IntDeinit(&x);- In
Math.c:3845:
bool ok = IntDivMod(&q, &r, &dvd, &dvs);
ok = ok && IntIsZero(&q) && IntToU64(&r) == 50u;
IntDeinit(&dvd);- In
Math.c:4036:
bool ok = IntRootRem(&root, &rem, &v, 3); // 100^3 = 1e6
ok = ok && IntToU64(&root) == 100u && IntIsZero(&rem);
IntDeinit(&v);- In
Math.c:4056:
bool ok = IntRootRem(&root, &rem, &v, 3); // cbrt(1000)=10 exact actually
ok = ok && IntToU64(&root) == 10u && IntIsZero(&rem);
// and a genuinely inexact one
- In
Math.c:4231:
bool ok = IntModSub(&r, &x, &y, &m);
ok = ok && IntIsZero(&r);
IntDeinit(&x);- In
Math.c:4483:
Int r = IntFrom(9u, a);
bool ok = IntModSqrt(&r, &v, &m) && IntIsZero(&r);
IntDeinit(&v);- In
Math.c:4805:
// equal branch: 5 - 12 = 0 (mod 7)
Int a3 = IntFrom(5u, alloc), b3 = IntFrom(12u, alloc);
ok = ok && IntModSub(&r, &a3, &b3, &m) && IntIsZero(&r);
IntDeinit(&a1);- In
Convert.c:274:
bool result = IntBitLength(&zero) == 0;
result = result && IntIsZero(&zero);
result = result && (IntToU64(&zero, &error) == 0);
result = result && !error;- In
Convert.c:343:
bool result = !IntTryFromBinary(&value, "10a1");
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);- In
Convert.c:344:
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);
IntDeinit(&parsed);- In
Convert.c:361:
bool result = !IntTryFromStr(&value, "12x3");
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);- In
Convert.c:362:
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);
IntDeinit(&parsed);- In
Convert.c:379:
bool result = !IntTryFromHexStr(&value, "12g3");
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);- In
Convert.c:380:
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);
IntDeinit(&parsed);- In
Convert.c:397:
bool result = !IntTryFromStrRadix(&value, "102", 2);
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);- In
Convert.c:398:
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);
IntDeinit(&parsed);- In
Convert.c:415:
bool result = !IntTryFromStrRadix(&value, "10", 1);
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);- In
Convert.c:416:
result = result && IntIsZero(&parsed);
result = result && IntIsZero(&value);
IntDeinit(&parsed);- In
Convert.c:649:
bool result = !IntTryFromStrRadix(&value, "_", 10);
result = result && IntIsZero(&value);
IntDeinit(&value);- In
Convert.c:698:
bool result = ok_valid && (IntToU64(&valid) == 5);
result = result && rejected_radix;
result = result && IntIsZero(&invalid);
IntDeinit(&valid);- In
Convert.c:1416:
Int value = IntFromBytesLE(NULL, 0, ALLOCATOR_OF(&alloc));
bool result = IntIsZero(&value);
IntDeinit(&value);- In
Convert.c:1533:
bool result = !ok;
result = result && IntIsZero(&value);
StrDeinit(&hex);- In
Access.c:56:
bool test_int_is_zero(void) {
WriteFmt("Testing IntIsZero\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Access.c:63:
Int non_zero = IntFrom(1, &alloc.base);
bool result = IntIsZero(&zero);
result = result && !IntIsZero(&non_zero);- In
Access.c:64:
bool result = IntIsZero(&zero);
result = result && !IntIsZero(&non_zero);
IntDeinit(&zero);
Last updated on