[CODING] Help with Experience Points

From: Michael J. McGillick (mike@dungeon.tiac.net)
Date: 01/29/97


I've played on several different muds and I've noticed that when players
get to the higher levels, and they do a report on their statistics, their
experience points always show as negative numbers.  I believe the reason
for this is because the experience point variable was set up as an int
instead of an unsigned int and the after 2 billion and something
experience points, the numbers flip over to negative.

Now, I want to avoid this all together in my mud, and I want the
experience points to have the full unsigned int range of numbers.  I went
into structs.h and I changed the variable exp to an unsigned int.  I then
proceeded to generate my experience point tables in class.c.  I
subsequently got a slew of warning messages that said:

 class.c:2077: warning: decimal constant is so large that it is unsigned
 class.c:2078: warning: decimal constant is so large that it is unsigned
 class.c:2078: warning: decimal constant is so large that it is unsigned

Now, I get very nervous coding when I see a bunch of errors.  The code
compiled, and the mud runs, but what am I doing wrong?

As a side question, if I do a math problem with both an unsigned int and a
regular int, what will the result be?  ie.

   unsigned int one = 0;
            int two = 10;

   two - one = ?
   one - two = ?

would the results be signed or unsigned?

- Any help would be appreciated

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST