IntFromBinary
Description
Compatibility wrapper for IntTryFromBinary(...).
Success
Returns Parsed integer value, or zero on failure.
Failure
Returns a zero-initialised Int on a non-binary character, an empty digit run, or an allocation failure. Use IntTryFromBinary(...) when explicit failure propagation is required.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Compare.c:28:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);
bool result = IntCompare(&a, &b) < 0;- In
Compare.c:48:
Int a = IntFrom(41, &alloc.base);
Int b = IntFrom(42, &alloc.base);
Int c = IntFromBinary("000101010", &alloc.base);
bool result = IntLT(&a, &b);- In
Compare.c:72:
Int value = IntFrom(42, &alloc.base);
Int same = IntFromBinary("00101010", &alloc.base);
Int big = IntFrom(1, &alloc.base);- In
Compare.c:103:
Int a = IntFrom(42u, &alloc.base);
Int b = IntFromBinary("101010", &alloc.base);
Int c = IntFrom(0u, &alloc.base);
Int d = IntFrom(0u, &alloc.base);- In
Type.c:36:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("101101", &alloc.base);
IntClear(&value);- In
Type.c:53:
DefaultAllocator alloc = DefaultAllocatorInit();
Int original = IntFromBinary("1011", &alloc.base);
Int clone = IntClone(&original);- In
Math.c:94:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("110000", &alloc.base);
IntShiftRight(&value, 4);- In
Math.c:1925:
DefaultAllocator alloc = DefaultAllocatorInit();
Int ones = IntFromBinary("1111111", &alloc.base); // 127
Int one = IntFrom(1u, &alloc.base);
Int sum = IntInit(&alloc.base);- In
Convert.c:158:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("001011", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value);- In
Convert.c:252:
DefaultAllocator alloc = DefaultAllocatorInit();
Int lhs = IntFromBinary("0001011", ALLOCATOR_OF(&alloc));
Int rhs = IntFrom(11, ALLOCATOR_OF(&alloc));- In
Convert.c:269:
DefaultAllocator alloc = DefaultAllocatorInit();
Int zero = IntFromBinary("0", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&zero);
bool error = true;- In
Convert.c:290:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("0b1010_0011", ALLOCATOR_OF(&alloc));
bool result = IntToU64(&value) == 163;- In
Convert.c:335:
bool test_int_from_binary_invalid_digit(void) {
WriteFmt("Testing IntFromBinary invalid digit handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:339:
DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromBinary("10a1", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromBinary(&value, "10a1");- In
Convert.c:462:
bool test_int_from_binary_null(void) {
WriteFmt("Testing IntFromBinary NULL handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:466:
DefaultAllocator alloc = DefaultAllocatorInit();
IntFromBinary((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false;- In
Access.c:32:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("00101000", &alloc.base);
bool result = IntBitLength(&value) == 6;- In
Access.c:46:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("0001001000110100", &alloc.base);
bool result = IntByteLength(&value) == 2;- In
Access.c:148:
DefaultAllocator alloc = DefaultAllocatorInit();
Int value = IntFromBinary("1010000", &alloc.base);
Int zero = IntInit(&alloc.base);- In
Write.c:603:
Int big_dec = IntFromStr("123456789012345678901234567890", alloc_base);
Int hex_val = IntFromHexStr("deadbeefcafebabe1234", alloc_base);
Int bin_val = IntFromBinary("10100011", alloc_base);
Int oct_val = IntFrom(493, alloc_base);
Last updated on