IntTryToStr
Description
Convert an integer to a decimal string using the default allocator.
Parameters
| Name | Direction | Description |
|---|---|---|
out |
out | Destination string. |
value |
in | Integer to convert. |
Success
Returns true. *out holds the decimal representation of value.
Failure
Returns false on allocation failure. *out is left as an empty initialized Str.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:651:
}
bool IntTryToStr(Str *out, Int *value) {
ValidateInt(value);
return IntTryToStrAlloc(out, value, INT_BITS(value)->allocator);- In
Int.c:661:
ValidateInt(value);
if (!IntTryToStr(&result, value)) {
result = StrInit(INT_BITS(value)->allocator);
}
bool test_int_try_to_str_allocator_inheritance(void) {
WriteFmt("Testing IntTryToStr allocator behavior\n");
Int value = IntFrom(0xBEEF);
Last updated on