Skip to content

IntIsZero

IntIsZero

Description

Test whether the integer is zero.

Parameters

Name Direction Description
value in Integer to test

Usage example (from documentation)

  if (IntIsZero(&value)) { /* ... */ }

Returns

true when the integer is zero.

Usage example (Cross-references)

Usage examples (Cross-references)
        ValidateFloat(value);
    
        if (IntIsZero(&value->significand)) {
            value->negative = false;
            value->exponent = 0;
    bool FloatIsZero(Float *value) {
        ValidateFloat(value);
        return IntIsZero(&value->significand);
    }
    
        result.significand = IntFromStr(digits.data);
        result.negative    = negative && !IntIsZero(&result.significand);
        result.exponent    = float_sub_i64_checked(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_FATAL("log2 undefined for zero");
        }
    }
    
    bool IntIsZero(Int *value) {
        return IntBitLength(value) == 0;
    }
        ValidateInt(value);
    
        return !IntIsZero(value) && IntBitLength(value) == IntTrailingZeroCount(value) + 1;
    }
        int_validate_radix(radix);
    
        if (IntIsZero(value)) {
            return StrInitFromZstr("0");
        }
        Str result    = StrInit();
    
        while (!IntIsZero(&current)) {
            Int quotient = IntInit();
            u64 digit    = 0;
        Int acc    = IntInit();
    
        if (IntIsZero(a) || IntIsZero(b)) {
            IntDeinit(result);
            *result = acc;
            LOG_FATAL("quotient and remainder must be different objects");
        }
        if (IntIsZero(divisor)) {
            LOG_FATAL("Division by zero");
        }
        ValidateInt(divisor);
    
        if (IntIsZero(divisor)) {
            LOG_FATAL("Division by zero");
        }
    
        IntDivMod(&quotient, &remainder, dividend, divisor);
        if (!IntIsZero(&remainder)) {
            IntDeinit(&quotient);
            IntDeinit(&remainder);
        Int y = IntClone(b);
    
        while (!IntIsZero(&y)) {
            Int r = IntInit();
        ValidateInt(b);
    
        if (IntIsZero(a) || IntIsZero(b)) {
            Int zero = IntInit();
            int_replace(result, &zero);
        }
    
        if (IntIsZero(value)) {
            Int zero_root = IntInit();
            Int zero_rem  = IntInit();
                Int next = IntInit();
    
                if (IntEQ(&mid, &one) || IntIsZero(&mid)) {
                    IntDeinit(&high);
                    high = IntInit();
    
        IntSqrtRem(&root, &remainder, value);
        result = IntIsZero(&remainder);
    
        IntDeinit(&root);
        ValidateInt(value);
    
        if (IntIsZero(value) || IntBitLength(value) == 1) {
            return true;
        }
    
            IntRootRem(&root, &remainder, value, degree);
            exact = IntIsZero(&remainder);
    
            IntDeinit(&root);
        ValidateInt(n);
    
        if (IntIsZero(n) || IntIsEven(n)) {
            LOG_FATAL("n must be non-zero and odd");
        }
        IntMod(&aa, a, &nn);
    
        while (!IntIsZero(&aa)) {
            while (IntIsEven(&aa)) {
                u64 n_mod_8 = 0;
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
    
            (void)IntSub(&diff, &br, &ar);
            if (IntIsZero(&diff)) {
                Int zero = IntInit();
                int_replace(result, &zero);
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
        IntMod(&base_mod, base, modulus);
    
        while (!IntIsZero(&exp)) {
            if (int_is_odd(&exp)) {
                Int next = IntInit();
    
            IntShiftRight(&exp, 1);
            if (!IntIsZero(&exp)) {
                Int next = IntInit();
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
        new_r = IntClone(&reduced);
    
        while (!IntIsZero(&new_r)) {
            Int       q        = IntInit();
            Int       rem      = IntInit();
    
            IntMod(&mag_mod, &t.magnitude, modulus);
            if (t.negative && !IntIsZero(&mag_mod)) {
                (void)IntSub(&positive, modulus, &mag_mod);
            } else {
        ValidateInt(modulus);
    
        if (IntIsZero(modulus)) {
            LOG_FATAL("modulus is zero");
        }
        IntMod(&a, value, modulus);
    
        if (IntIsZero(&a)) {
            Int zero = IntInit();
            int_replace(result, &zero);
    
        bool result = IntBitLength(&zero) == 0;
        result      = result && IntIsZero(&zero);
        result      = result && (IntToU64(&zero) == 0);
        result      = result && (strcmp(text.data, "0") == 0);
    
    bool test_int_is_zero(void) {
        WriteFmt("Testing IntIsZero\n");
    
        Int zero     = IntInit();
        Int non_zero = IntFrom(1);
    
        bool result = IntIsZero(&zero);
        result      = result && !IntIsZero(&non_zero);
    
        bool result = IntIsZero(&zero);
        result      = result && !IntIsZero(&non_zero);
    
        IntDeinit(&zero);
        IntMul(&result_value, &a, &b);
    
        bool result = IntIsZero(&result_value);
        result      = result && (IntToU64(&result_value) == 0);
        Int value = IntInit();
    
        bool result = IntIsZero(&value);
        result      = result && (IntBitLength(&value) == 0);
        IntClear(&value);
    
        bool result = IntIsZero(&value);
        result      = result && (IntBitLength(&value) == 0);
Last updated on