Skip to content
IntTryToStrAlloc

IntTryToStrAlloc

Description

Convert an integer to a decimal string using an explicit allocator.

Parameters

Name Direction Description
out out Destination string.
value in Integer to convert.
alloc in Allocator to bind to the produced string.

Success

Returns true on success, false on allocation failure.

Usage example (Cross-references)

Usage examples (Cross-references)
        *out = StrInit(alloc);
    
        if (!IntTryToStrAlloc(&digits, &value->significand, alloc)) {
            return false;
        }
    
        if (radix == 10) {
            if (!IntTryToStrAlloc(&temp, value, o->allocator)) {
                return false;
            }
        }
    
        if (!IntTryToStrAlloc(&digits, &value->significand, alloc)) {
            return false;
        }
    }
    
    bool IntTryToStrAlloc(Str *out, Int *value, Allocator alloc) {
        return IntTryToStrRadixAlloc(out, value, 10, false, alloc);
    }
    bool IntTryToStr(Str *out, Int *value) {
        ValidateInt(value);
        return IntTryToStrAlloc(out, value, INT_BITS(value)->allocator);
    }
Last updated on