Re: [Code] 5 = 7?!?

From: Angus Mezick (angus@EDGIL.CCMAIL.COMPUSERVE.COM)
Date: 11/25/97


     hmmm.... why are you doing this, is there a better way?

     char tmpp[10];
     sprintf(tmpp,"%09d",world[ch->in_room]);
     then look in the correct place in tmpp..
     --Angus


______________________________ Reply Separator _________________________________
Subject:  [Code] 5 = 7?!?
Author:  INTERNET:CIRCLE@post.queensu.ca at CSERVE
Date:    11/25/97 10:17 AM

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.


     +------------------------------------------------------------+
     | 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