mIRC Homepage

Calculating..

Posted By: phrozenfire

Calculating.. - 21/04/03 11:59 AM

Is there anyway I could calculate this in mIRC (using a $calc for example):



If you don't understand that, here it is in JavaScript (this JavaScript loops through minlevel all the way to maxlevel and displays it):

Code:
points = 0;

outputnum = 0;
minlevel = 2;		// first level to display
maxlevel = 500;		// last level to display
for (lvl = 1; lvl <= maxlevel; outputnum = Math.floor(points / 4), lvl++) {

	diff = Math.floor(lvl + 300 * Math.pow(2, lvl / 7));
                     points += diff;
                     if (lvl >= minlevel) {

		document.writeln('Level ' + (lvl) + ' - ' + outputnum + ' xp');

	}

}

And here it is in Python:
Code:
points = 0
diff = int(level + 300 * math.pow(2, float(level)/7) )
points += diff
str = "Level %d = %d" % (level + 1, points / 4)
print str


Please help.
Posted By: dukey

Re: Calculating.. - 21/04/03 07:27 PM

yeah its perfectly possible
im not gonna write the code for u but it might help if you wrote a floor alias perhaps smile
up to u
Posted By: codemastr

Re: Calculating.. - 21/04/03 08:20 PM

If I'm remembering my math correctly, doesn't $int() serve the same function as floor? At least in a coding sense. Graphically [x] and |_x_| look slightly different.
Posted By: phrozenfire

Re: Calculating.. - 21/04/03 08:20 PM

Yes, but the thing is, i dont even understand what floor is. I'm only in 7th grade. If anybody could help me with this, please do. Thanks.

I also don't understand what I do with the Sigma (I think that's Sigma)..
Posted By: codemastr

Re: Calculating.. - 21/04/03 08:45 PM

Umm well floor(x) returns the highest ingeter <= x. For example:

floor(1) = 1
floor(1.1) = 1
floor(1.9) = 1
floor(2.1) = 2

For example,

Sigma(x=1,3,x+2)

What that says is for all x (integers) beginning at x=1 and ending at x=3, apply the formula x+2 to each of them and return the total. ie:

x=1
1+2 = 3
total = 3
x=2
2+2 = 4
total = 7
3+2 = 5
total=12

So the summation from x=1 to x=3 of x+2 is 12. If you don't really follow that, well now you know why floor and summation are taught in advanced math classes and not in 7th grade smile
Posted By: gerdigos

Re: Calculating.. - 22/04/03 02:17 PM

phrozenfire i'm Greek and that's a Sigma smile
© 2020 mIRC Discussion Forums