IntToStr
Description
Convert an integer to a decimal string. Two forms via argument count:
IntToStr(value)- usesvalue’s allocator.IntToStr(value, alloc)- uses the explicit allocator.
Success
Returns a Str holding the base-10 textual form of value.
Failure
Returns an empty Str bound to alloc when the underlying IntTryToStr fails (intermediate allocation failure); the caller cannot distinguish that from a true empty result, so callers that need to detect failure should use IntTryToStr directly.
Usage example (Cross-references)
Usage examples (Cross-references)
Zstr digits = "123456789012345678901234567890";
Int value = IntFromStr(digits, ALLOCATOR_OF(&alloc));
Str text = IntToStr(&value);
bool result = ZstrCompare(StrBegin(&text), digits) == 0;- In
Io.Read.c:899:
z = "123456789012345678901234567890";
StrReadFmt(z, "{}", dec);
dec_text = IntToStr(&dec);
success = success && (ZstrCompare(StrBegin(&dec_text), "123456789012345678901234567890") == 0);
bool result = FloatToInt(&result_value, &value);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "12345") == 0);- In
Int.Math.c:141:
IntAdd(&result_value, &huge, 10);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "123456789012345678901234567900") == 0);- In
Int.Math.c:194:
result = result && IntSub(&result_value, &huge, 90);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "12345678901234567800") == 0);- In
Int.Math.c:259:
IntMul(&result_value, &value, 25u);
text = IntToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "308641972530864197250") == 0;- In
Int.Math.c:320:
IntPow(&result_value, &base, 20u);
text = IntToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "79792266297612001") == 0;- In
Int.Math.c:325:
StrDeinit(&text);
IntPow(&result_value, &base, &exponent);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "79792266297612001") == 0);- In
Int.Math.c:347:
IntDivMod("ient, &remainder, ÷nd, 97u);
qtext = IntToStr("ient);
bool result = ZstrCompare(StrBegin(&qtext), "127275040218913071") == 0;- In
Int.Math.c:388:
bool result = IntDivExact(&result_value, ÷nd, 90u);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "137174210013717421") == 0);- In
Int.Math.c:428:
IntDivMod("ient, &remainder, ÷nd, 97);
text = IntToStr("ient);
bool result = ZstrCompare(StrBegin(&text), "127275040218913071") == 0;- In
Int.Math.c:898:
bool ok = IntNextPrime(&next, &value);
text = IntToStr(&next);
bool result = ok && ZstrCompare(StrBegin(&text), "1000000007") == 0;
Last updated on