Increasing values

Posted by Zeno on Sun 22 Jun 2003 01:03 AM — 14 posts, 29,656 views.

USA #0
Is there a variable (like int or sh_int) that holds more than 1 billion? I wish to use it for gold or exp of the such.
USA #1
Quick rundown for length of common numeric variable types:

short        32, 767
int/long     2,147,483,647
float        ~10^38
double       ~10^308
long double  ~10^4392
USA #2
So if I were to change in mud.h -
 int          exp

to
 double       exp

it would increase how the value of how high it can hold exp?
Amended on Sun 22 Jun 2003 05:19 PM by Zeno
USA #3
Yep, thats about the extent of it.


dbl     exp


rather than


double exp
Amended on Sun 22 Jun 2003 06:42 PM by Meerclar
USA #4
Ok, when I did that I got a bunch of error while compiling.

 dereferencing pointer to incomplete type

All over
Australia Forum Administrator #5
I tried that and got no errors, however I would be a bit worried about display routines that expect a long but get passed a double.
Australia Forum Administrator #6
You could also try a "long long" which will give you 9,223,372,036,854,775,807 (signed) experience points. However you still have the problem of changing appropriate displays so they know they are getting a long long.
USA #7
Hmm, if you tried that and it worked than perhaps I am not doing it correctly. Around line 2288

    sh_int              numattacks;
    dbl                 gold;
    int                 exp;
    EXT_BV              act;

After doing a clean recompile I get a lot of

act_comm.c: In function `talk_auction':
act_comm.c:2939: dereferencing pointer to incomplete type
act_comm.c:2940: dereferencing pointer to incomplete type

Thats just an example of what I get, there's a lot more of the same.
USA #8
The functions that were being passed a gold value are expecting an int value and will all need to be changed to reflect the change of the gold data type to dbl.
Australia Forum Administrator #9
dbl - what's that?

The C data type is "double". I did get a warning this time in build.c, for printing exp, on this line:


        fprintf( fpout, "%d %d\n",      pMobIndex->gold,
                                        pMobIndex->exp                  );


The error was:


buildc:5971: warning: int format, double arg (arg 4)
USA #10
Sorry, too much vb code lately I guess. Yes, C is double for data type.
USA #11
Err, so what do I use? dbl or double?
USA #12
Would use double for the value changes but you would need to change any struct that references the value changed to expect double instead of int.
USA #13
Alright, I see. I'm doing that now, but I think an example would help me of changing any struct references, so if anyone could provide one, it would help me so much.