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)
- In
Type.c:211:
bool ok = FloatToInt(&result, &value);
Str text = IntToStr(&result);
bool right = ok && (ZstrCompare(StrBegin(&text), "5") == 0);- In
Type.c:232:
bool ok = FloatToInt(&result, &value);
Str text = IntToStr(&result);
bool right = ok && (ZstrCompare(StrBegin(&text), "120") == 0);- In
Convert.c:110:
bool result = FloatToInt(&result_value, &value);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "12345") == 0);- In
Math.c:151:
IntAdd(&result_value, &huge, 10);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "123456789012345678901234567900") == 0);- In
Math.c:204:
result = result && IntSub(&result_value, &huge, 90);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "12345678901234567800") == 0);- In
Math.c:269:
IntMul(&result_value, &value, 25u);
text = IntToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "308641972530864197250") == 0;- In
Math.c:330:
IntPow(&result_value, &base, 20u);
text = IntToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "79792266297612001") == 0;- In
Math.c:335:
StrDeinit(&text);
IntPow(&result_value, &base, &exponent);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "79792266297612001") == 0);- In
Math.c:357:
IntDivMod("ient, &remainder, ÷nd, 97u);
qtext = IntToStr("ient);
bool result = ZstrCompare(StrBegin(&qtext), "127275040218913071") == 0;- In
Math.c:398:
bool result = IntDivExact(&result_value, ÷nd, 90u);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "137174210013717421") == 0);- In
Math.c:438:
IntDivMod("ient, &remainder, ÷nd, 97);
text = IntToStr("ient);
bool result = ZstrCompare(StrBegin(&text), "127275040218913071") == 0;- In
Math.c:908:
bool ok = IntNextPrime(&next, &value);
text = IntToStr(&next);
bool result = ok && ZstrCompare(StrBegin(&text), "1000000007") == 0;- In
Math.c:2450:
bool ok = int_div_mod_u64("ient, &remainder, ÷nd, 97u);
qtext = IntToStr("ient);
bool result = ok;- In
Math.c:2480:
bool ok = int_div_mod_i64("ient, &remainder, ÷nd, (i64)13);
qtext = IntToStr("ient);
bool result = ok;- In
Math.c:3159:
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);
Str qtext = IntToStr("ient);
Str rtext = IntToStr(&remainder);- In
Math.c:3160:
Str qtext = IntToStr("ient);
Str rtext = IntToStr(&remainder);
bool result = ok;- In
Convert.c:177:
Zstr digits = "123456789012345678901234567890";
Int value = IntFromStr(digits, ALLOCATOR_OF(&alloc));
Str text = IntToStr(&value);
bool result = ZstrCompare(StrBegin(&text), digits) == 0;- In
Read.c:927:
z = "123456789012345678901234567890";
StrReadFmt(z, "{}", dec);
dec_text = IntToStr(&dec);
success = success && (ZstrCompare(StrBegin(&dec_text), "123456789012345678901234567890") == 0);- In
Read.c:2568:
Zstr z = "12345";
StrReadFmt(z, "{}", v);
Str t = IntToStr(&v);
bool ok = (ZstrCompare(StrBegin(&t), "12345") == 0);
StrDeinit(&t);- In
Read.c:2583:
Zstr z = "+99";
StrReadFmt(z, "{}", v);
Str t = IntToStr(&v);
bool ok = (ZstrCompare(StrBegin(&t), "99") == 0);
StrDeinit(&t);- In
Read.c:2599:
Zstr z = "ff";
StrReadFmt(z, "{x}", v);
Str t = IntToStr(&v);
bool ok = (ZstrCompare(StrBegin(&t), "255") == 0);
StrDeinit(&t);- In
Read.c:2617:
// Real: '_' rejected -> returns start (==z) -> str_read_fmt sees next==in ->
// NULL; v unchanged (still 777).
Str t = IntToStr(&v);
bool ok = (out == NULL) && (ZstrCompare(StrBegin(&t), "777") == 0);
StrDeinit(&t);
Last updated on