Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8546529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:02:55+00:00 2026-06-11T13:02:55+00:00

I wanted to make a custom ITOA function to put large numbers into small

  • 0

I wanted to make a custom ITOA function to put large numbers into small strings, this is what I have coded :

main(){
    printf("itoa(2000000000,36)= '%s'",itoa(2000000000,36));
    printf("itoa(36,36)= '%s'",itoa(36,36));
    printf("itoa(37,36)= '%s'",itoa(37,36));

    return 1;
}

stock itoa(val, base)
{
    new buf[1024] = {0,...};
    new i = 1023;
    new LETTERZ[37] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
    for(; val && i; --i, val /= base)
        buf[i] = LETTERZ[val % base];
    return buf[i+1];
}

It’s based on ‘C’ code from this page: http://www.jb.man.ac.uk/~slowe/cpp/itoa.html

But somehow this is the output:

[20:34:35] itoa(2000000000,36)= ‘X’
[20:34:35] itoa(36,36)= ‘1’
[20:34:35] itoa(37,36)= ‘1’

And this is totally wrong, I don’t know which output to expect but 36 and 37 for sure can’t be the same output and 2 000 000 000 can’t be just ‘X’, as X is suposed to be 35, not 2 000 000 000,
ZZ should be 1295 I think… I want to base this on the hexadecimal system, but with all the alfabet letters.

Could anyone tell me what’s wrong here?

I’m working with a typeless language called PAWN (also known as SMALL) and later i want to use this code in VB.NET

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:02:56+00:00Added an answer on June 11, 2026 at 1:02 pm

    THe solution seemed to be simple, the return buf[i+1] just returned one character so what I did is make it return an array:

    new _s@T[4096];
    #define sprintf(%1) (format(_s@T, SPRINTF_MAX_STRING, %1), _s@T)
    
    main(){
        new num = atoi("ABCDEFG",36);
        printf("%d",num);
        printf("%s",itoa(num,36));
    
        return 1;
    }
    
    stock itoa(val, base)
    {
        new buf[1024] = {0,...};
        new LETTERZ[37] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
        for(new pos = 0; val;++pos,val = floatround(val/base,floatround_floor))
            strins(buf,sprintf("%c",LETTERZ[val % base]),0);
        return buf;
    }
    
    stock atoi(val[], base)
    {
        new CURRNUM = 0;
        new len = strlen(val);
        new LETTERZ[37] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
        for(new i = 0; i < len; ++i)
        {
            for(new x = 0; x < base; ++x)
            {
                new y = (len-i)-1;
                if(val[y] == LETTERZ[x])
                {
                    CURRNUM += x*floatround(floatpower(base,i));
                }
            }
        }
        return CURRNUM;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to make a basic custom keypad for the iPhone , I did
I wanted to make a function that populates a Grid in WPF with pictures.
I wanted to make a post request in this website: http://www.prezup.info/index.php?page=films in order to
I wanted to see if I could make a custom data set to use
I wanted to make custom social buttons (with Like links to Facebook, share links
I'm creating a custom control and wanted to make it generic enough to use
I created a custom view class because I wanted to have a status item
i've always wanted to make some of our companies products open-source..but we have a
I wanted to make two equally-sized radio buttons with a custom background, text, and
i have created a custom user control which im using on my main xaml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.