Max int

Posted by Dace K on Tue 16 Sep 2003 06:22 AM — 11 posts, 32,176 views.

Canada #0
Hey, is there any way to increase max integer from
2,147,483,647? :P
I'd appreciate any help..
USA #1
Not too likely, no. That's system dependent. You could use "long" types though if you REALLY want to have gigantic numbers available.
USA #2
unsigned long long stores a large number, more than a trillion. That should be enough for whatever you need. You'll need to use %llu also.
Canada #3
Never worked with ull before,
can you go a bit more into detail on the code
to assign it to a value? :P
Thanks.
Amended on Tue 16 Sep 2003 11:55 PM by Dace K
Canada #4
Er.. I took a look around the forums, and as far
as I can tell, this would be what I should do..

unsigned long long <value>;

and then change every %d display for that value
to %llu.

That right? ;)
USA #5
Yeah, thats right. One thing that I found a problem with it, is that the num_punct doesn't work with it. You have to make a new num_punct function. If your going to use comma's, then I'll gladly post the new function. Just ask.

[EDIT] Argh, typos.
Amended on Wed 17 Sep 2003 02:00 AM by Zeno
Canada #6
Updated code, it works like a dream. Thanks :).
I was gonna rewrite the num_punct myself, but if you have one handy I'd love to use it instead :D

Amended on Wed 17 Sep 2003 01:58 AM by Dace K
USA #7
Well, I wouldn't rewrite it, then the old variables like int may not display corretly. I made a new num_punct function right under it called num_punct_llu. If you run into trouble making it, I'll just post mine.
Canada #8
Well, I wrote a function for num_punct_llu(long long foo)..
compiled it with no errors except for a warning where the function is called, so it completely fails to work.
Could you post your func please? :D
USA #9
Sure. Under num_punct this should go

char *num_punct_llu(long long unsigned foo)
{
    int index, index_new, rest;
    char buf[16];
    static char buf_new[16];

    sprintf(buf,"%llu",foo);
    rest = strlen(buf)%3;

    for (index=index_new=0;index<strlen(buf);index++,index_new++)
    {
        if (index!=0 && (index-rest)%3==0 )
        {
            buf_new[index_new]=',';
            index_new++;
            buf_new[index_new]=buf[index];
        }
        else
            buf_new[index_new] = buf[index];
    }
    buf_new[index_new]='\0';
    return strdup(buf_new);
}

When you use this for a variable, don't use %llu, since its already used in here. Just use %s. For example.

pager_printf_color(ch, "Variable: %s\n\r", num_punct_llu(ch->vr) );
Canada #10
ahhh. My function was correct then, I just needed to change
the calls from %llu to %s.
Thanks for your help.