Re: [OLC][MEDIT] mob max level

From: David Sun (wedget@MCI2000.COM)
Date: 09/04/98

Matt Roach wrote:
> Ok, I got bored today so I was pissing around with medit.c and figured I'd
> set the max number of levels you could have to about 5000, but when I
> tried to make a mob over level 120 in medit, it goes to negitives, why?

levels are stored in 1 signed byte. so 8 bits are used. with signed
numbers, 1 bit is unsed to store the positive/negative info, and the
remaining (7 in this case) are used to store the absolute number.
2^7 is 127. for the sake of speed, the computer doesn't check to see
if you go over 127. so when you [accidently] do, it "overflows" into
the 8th bit, where the positive/negative info is. you set the 8th bit
on, which turns the entire number negative. here's a picture now:

signed byte:
0 1 1 1 1 0 0 1
+- the positive/negative flag

> And yes I know there is prolly same lame little SIMPLE answer so please do
> not flame me telling me how stupid I am.

don't say that. it makes >some< people want to flame you more.

"The optimist sees the doughnut, the pessimist sees the hole."

char c[160],z;main(x,d){for/*/      -- Wedge --       /*/(x=159;x--
;c[x]=32);c[79]=z;c[39]=88/*/   /*/;for(d=31;x
=78,puts(c+z),d--;z=80-z)/*/   high school junior   /*/for(;--x;c[x
+80-z]=88-56*!(c[z-!0+x]/*/   mud and game coder   /*/-c[z+x+1]));}

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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