Skip to content

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)
        ValidateFloat(value);
    
        if (IntIsZero(&value->significand)) {
            value->negative = false;
            value->exponent = 0;
    bool FloatIsZero(const Float *value) {
        ValidateFloat(value);
        return IntIsZero(&value->significand);
    }
        }
    
        result.negative = negative && !IntIsZero(&result.significand);
        result.exponent = explicit_exp - fractional;
    static void sint_normalize(SignedInt *value) {
        int_normalize(&value->magnitude);
        if (IntIsZero(&value->magnitude)) {
            value->negative = false;
        }
        SignedInt neg_b = sint_clone(b);
    
        if (!IntIsZero(&neg_b.magnitude)) {
            neg_b.negative = !neg_b.negative;
        }
        ValidateInt(value);
    
        if (IntIsZero(value)) {
            LOG_ERROR("log2 undefined for zero");
            return false;
    }
    
    bool IntIsZero(const Int *value) {
        return IntBitLength(value) == 0;
    }
        ValidateInt(value);
    
        return !IntIsZero(value) && IntBitLength(value) == IntTrailingZeroCount(value) + 1;
    }
        }
    
        if (IntIsZero(value)) {
            return StrPushBackR(out, '0');
        }
    
        current = IntClone(value);
        if (IntIsZero(&current)) {
            return false;
        }
        result = StrInit(alloc);
    
        while (!IntIsZero(&current)) {
            Int quotient = IntInit(alloc);
            u64 digit    = 0;
        Int acc    = IntInit(IntAllocator(result));
    
        if (IntIsZero(a) || IntIsZero(b)) {
            IntDeinit(result);
            *result = acc;
            LOG_FATAL("quotient and remainder must be different objects");
        }
        if (IntIsZero(divisor)) {
            LOG_ERROR("Division by zero");
            return false;
        ValidateInt(divisor);
    
        if (IntIsZero(divisor)) {
            LOG_ERROR("Division by zero");
            return false;
            return false;
        }
        if (!IntIsZero(&remainder)) {
            IntDeinit(&quotient);
            IntDeinit(&remainder);
        }
    
        while (!IntIsZero(&y)) {
            Int r = IntInit(IntAllocator(result));
        ValidateInt(b);
    
        if (IntIsZero(a) || IntIsZero(b)) {
            Int zero = IntInit(IntAllocator(result));
            int_replace(result, &zero);
        }
    
        if (IntIsZero(value)) {
            Int zero_root = IntInit(IntAllocator(root));
            Int zero_rem  = IntInit(IntAllocator(remainder));
                Int next = IntInit(IntAllocator(root));
    
                if (IntEQ(&mid, &one) || IntIsZero(&mid)) {
                    IntDeinit(&high);
                    high = IntInit(IntAllocator(root));
            return false;
        }
        result = IntIsZero(&remainder);
    
        IntDeinit(&root);
        ValidateInt(value);
    
        if (IntIsZero(value) || IntBitLength(value) == 1) {
            return true;
        }
                return false;
            }
            exact = IntIsZero(&remainder);
    
            IntDeinit(&root);
        }
    
        if (IntIsZero(n) || IntIsEven(n)) {
            LOG_ERROR("n must be non-zero and odd");
            return false;
        }
    
        while (!IntIsZero(&aa)) {
            while (IntIsEven(&aa)) {
                u64 n_mod_8 = 0;
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_ERROR("modulus is zero");
            return false;
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_ERROR("modulus is zero");
            return false;
                return false;
            }
            if (IntIsZero(&diff)) {
                Int zero = IntInit(IntAllocator(result));
                int_replace(result, &zero);
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_ERROR("modulus is zero");
            return false;
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_ERROR("modulus is zero");
            return false;
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_ERROR("modulus is zero");
            return false;
        }
    
        while (!IntIsZero(&exp)) {
            if (int_is_odd(&exp)) {
                Int next = IntInit(IntAllocator(result));
                return false;
            }
            if (!IntIsZero(&exp)) {
                Int next = IntInit(IntAllocator(result));
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_ERROR("modulus is zero");
            return false;
        }
    
        while (!IntIsZero(&new_r)) {
            Int       q       = IntInit(IntAllocator(result));
            Int       rem     = IntInit(IntAllocator(result));
                return false;
            }
            if (t.negative && !IntIsZero(&mag_mod)) {
                if (!int_sub(&positive, modulus, &mag_mod)) {
                    IntDeinit(&positive);
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_ERROR("modulus is zero");
            return false;
        }
    
        if (IntIsZero(&a)) {
            Int zero = IntInit(IntAllocator(result));
            int_replace(result, &zero);
    
    bool test_int_is_zero(void) {
        WriteFmt("Testing IntIsZero\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Int non_zero = IntFrom(1, &alloc.base);
    
        bool result = IntIsZero(&zero);
        result      = result && !IntIsZero(&non_zero);
    
        bool result = IntIsZero(&zero);
        result      = result && !IntIsZero(&non_zero);
    
        IntDeinit(&zero);
    
        bool result = IntBitLength(&zero) == 0;
        result      = result && IntIsZero(&zero);
        result      = result && (IntToU64(&zero, &error) == 0);
        result      = result && !error;
        bool result = !IntTryFromBinary(&value, "10a1");
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromStr(&value, "12x3");
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromHexStr(&value, "12g3");
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromStrRadix(&value, "102", 2);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromStrRadix(&value, "10", 1);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromBinary(&value, (Zstr)NULL);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromStr(&value, (Zstr)NULL);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromStrRadix(&value, (Zstr)NULL, 10);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromOctStr(&value, (Zstr)NULL);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        bool result = !IntTryFromHexStr(&value, (Zstr)NULL);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        result = result && IntIsZero(&parsed);
        result = result && IntIsZero(&value);
    
        IntDeinit(&parsed);
        Int value = IntInit(&alloc.base);
    
        bool result = IntIsZero(&value);
        result      = result && (IntBitLength(&value) == 0);
        IntClear(&value);
    
        bool result = IntIsZero(&value);
        result      = result && (IntBitLength(&value) == 0);
        IntMul(&result_value, &a, &b);
    
        bool result = IntIsZero(&result_value);
        result      = result && (IntToU64(&result_value) == 0);
Last updated on