Skip to content

IntToStr

IntToStr

Description

Convert an integer to a decimal string.

Parameters

Name Direction Description
value in Integer to convert

Usage example (from documentation)

  Str text = IntToStr(&value);

Returns

Decimal representation of the integer.

Usage example (Cross-references)

Usage examples (Cross-references)
    
    static Str FloatFmtToScientificStr(Float *value, u32 precision, bool has_precision, bool uppercase) {
        Str digits = IntToStr(&value->significand);
        Str result = StrInit();
        u64 frac_digits = 0;
    
        if (radix == 10) {
            temp = IntToStr(value);
        } else {
            temp = IntToStrRadix(value, radix, (fmt_info->flags & FMT_FLAG_CAPS) != 0);
        }
    
        digits = IntToStr(&value->significand);
    
        if (value->negative) {
    }
    
    Str IntToStr(Int *value) {
        return IntToStrRadix(value, 10, false);
    }
        const char *digits = "123456789012345678901234567890";
        Int         value  = IntFromStr(digits);
        Str         text   = IntToStr(&value);
    
        bool result = strcmp(text.data, digits) == 0;
        z = "123456789012345678901234567890";
        StrReadFmt(z, "{}", dec);
        dec_text = IntToStr(&dec);
        success  = success && (ZstrCompare(dec_text.data, "123456789012345678901234567890") == 0);
    
        bool result = FloatToInt(&result_value, &value);
        text        = IntToStr(&result_value);
        result      = result && (strcmp(text.data, "12345") == 0);
    
        IntAdd(&result_value, &huge, 10);
        text   = IntToStr(&result_value);
        result = result && (strcmp(text.data, "123456789012345678901234567900") == 0);
    
        result = result && IntSub(&result_value, &huge, 90);
        text   = IntToStr(&result_value);
        result = result && (strcmp(text.data, "12345678901234567800") == 0);
    
        IntMul(&result_value, &value, 25u);
        text = IntToStr(&result_value);
    
        bool result = strcmp(text.data, "308641972530864197250") == 0;
    
        IntPow(&result_value, &base, 20u);
        text   = IntToStr(&result_value);
        bool result = strcmp(text.data, "79792266297612001") == 0;
        StrDeinit(&text);
        IntPow(&result_value, &base, exponent);
        text   = IntToStr(&result_value);
        result = result && (strcmp(text.data, "79792266297612001") == 0);
    
        IntDivMod(&quotient, &remainder, &dividend, 97u);
        qtext = IntToStr(&quotient);
    
        bool result = strcmp(qtext.data, "127275040218913071") == 0;
    
        bool result = IntDivExact(&result_value, &dividend, 90u);
        text = IntToStr(&result_value);
        result = result && (strcmp(text.data, "137174210013717421") == 0);
    
        IntDivMod(&quotient, &remainder, &dividend, 97);
        text = IntToStr(&quotient);
    
        bool result = strcmp(text.data, "127275040218913071") == 0;
    
        IntNextPrime(&next, &value);
        text = IntToStr(&next);
    
        bool result = strcmp(text.data, "1000000007") == 0;
Last updated on