[Code] 5 = 7?!?

From: Soren P. Skou (serces@MUD.DK)
Date: 11/25/97


Wee all..


Now I give up, this doesn't make *ANY* sense to me what so ever,
howcome 5 sometimes is 7 other times is 5...

Below is the code, and here is what I do with it, it's supposed to be
the portal spell I made some time back, someone complained that it
kept rebooting the mud. and that's about it. Now, I've figured this
situation out to give an example :

I'm standing in room 05719,  So what I basically need is that :
tenthousands = 0
thousands = 5
hundreds = 7
tens = 1
ones = 9

Very simple and using the below code, this acutally works, MOST of
the time. the rest of the time hundreds is all of a sudden 5??? I
really don't get this.


roomno = world[ch->in_room].number;
ones = roomno % 10;            /* 12345 = 5    */
tmp = roomno / 10;                 /* 12345 = 1234 */
tens = tmp % 10;                    /* 1234  = 4    */
tmp = tmp / 10;                        /* 1234  = 123  */
hundreds = tmp % 10;         /* 123   = 3    */
tmp = tmp / 10;                      /* 123   = 12   */
thousands = tmp % 10;       /* 12    = 2    */
if (tmp > 0)
 tenthousands = tmp / 10;   /* 12    = 1    */
else
 tenthousands = 0;

If anyone can see the error or find a better way, then please tell
me. :) I'll update the portal/arcane name spell after that.

*cry* Help.

/Serces


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



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