Skip to content

IntFitsU64

Description

Test whether the integer’s magnitude fits in a 64-bit unsigned value.

Parameters

Name Direction Description
value in Integer to inspect.

Success

Returns true when value <= UINT64_MAX.

Failure

Returns false when the value exceeds 64 bits.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool IntFitsU64(const Int *value) {
        ValidateInt(value);
        return IntBitLength(value) <= 64;
        ValidateInt(value);
    
        if (!IntFitsU64(value)) {
            LOG_ERROR("Int value exceeds u64 range");
            return false;
        ValidateInt(exponent);
    
        if (!IntFitsU64(exponent)) {
            LOG_ERROR("Int exponent exceeds u64 range");
            return false;
    
    bool test_int_fits_u64(void) {
        WriteFmt("Testing IntFitsU64\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        IntShiftLeft(&big, 64);
    
        bool result = IntFitsU64(&small);
        result      = result && !IntFitsU64(&big);
    
        bool result = IntFitsU64(&small);
        result      = result && !IntFitsU64(&big);
    
        IntDeinit(&small);
Last updated on