IntFromHexStr
Description
Compatibility wrapper for IntTryFromHexStr(...).
Success
Returns Parsed integer value, or zero on failure.
Failure
Returns a zero-initialised Int on a non-hex character (including underscore or a 0x prefix), an empty digit run, or an allocation failure. Use IntTryFromHexStr(...) when explicit failure propagation is required.
Usage example (Cross-references)
Usage examples (Cross-references)
Zstr hex = "deadbeefcafebabe1234";
Int value = IntFromHexStr(hex, ALLOCATOR_OF(&alloc));
Str text = IntToHexStr(&value);
bool test_int_from_hex_invalid_digit(void) {
WriteFmt("Testing IntFromHexStr invalid digit handling\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromHexStr("12g3", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, "12g3");
bool test_int_from_hex_null(void) {
WriteFmt("Testing IntFromHexStr NULL handling\n");
DefaultAllocator alloc = DefaultAllocatorInit(); DefaultAllocator alloc = DefaultAllocatorInit();
Int parsed = IntFromHexStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool result = !IntTryFromHexStr(&value, (Zstr)NULL);- In
Io.Write.c:595:
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