Skip to content
FloatTryToStrAlloc

FloatTryToStrAlloc

Description

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

Parameters

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

Success

Returns true. The result has been computed and the destination object updated.

Failure

Returns false on allocation failure. The destination is left in a valid but unspecified state on partial failure.

Usage example (Cross-references)

Usage examples (Cross-references)
        *out = StrInit(alloc);
    
        if (!FloatTryToStrAlloc(&canonical, value, alloc)) {
            return false;
        }
    }
    
    bool FloatTryToStrAlloc(Str *out, Float *value, Allocator alloc) {
        Str digits;
        Str result;
    bool FloatTryToStr(Str *out, Float *value) {
        ValidateFloat(value);
        return FloatTryToStrAlloc(out, value, value->significand.bits.allocator);
    }
        alloc.retry_limit = 5;
    
        ok = FloatTryToStrAlloc(&text, &value, alloc);
    
        bool result = ok && (ZstrCompare(text.data, "-123.45") == 0) && (text.allocator.effort == alloc.effort) &&
Last updated on