Hey,
I've run into a little bit of trouble with the PrintSummary.
formatnumber(((int(shortdata(i,13))int(shortdata(i,3)))/shortdata(i,13))*100,2)
Can someone please explain what the the formatnumber function and
exactly whats being done.
Thanks
Nos.
Number Formatting

 Comfortable with my sexuality
 Posts: 1408
 Joined: Fri Dec 02, 2005 7:57 am
 Location: Horse country
Re: Number Formatting
nos wrote:Hey,
I've run into a little bit of trouble with the PrintSummary.
formatnumber(((int(shortdata(i,13))int(shortdata(i,3)))/shortdata(i,13))*100,2)
Can someone please explain what the the formatnumber function and
exactly whats being done.
Thanks
Nos.
formatnumber is a builtin ASP function
formatnumber(x,p)
first param is the number you want to round, second param is how many decimal places  PHP uses round(x,p) to do the same thing.
What the bit of code is doing is working out how much of your total career points are from winning awards as opposed to shooting people, and returning it as a percentage, rounded to two decimal places. (career  score/career). Maybe you should have the stats page open in your browser while you work so you can see what the output is.
Re: Number Formatting
yea thanks piers I figured as much, but that it explains it nicely
thanks I got it all working now.
you can use the round function with php but i used the number_format function.
edit*****
I'm still having trouble formatting the Score per min.
ASP original code.
I can see its global score divided by time played(seconds) divided by 60.
but i cant get the right result.
also what does the field cppm represent?
other then those 2 values i have the Print summary finished and I have made
a start on the big stats so everythings moving along well.
Thanks
Nos
thanks I got it all working now.
you can use the round function with php but i used the number_format function.
Code: Select all
number_format(($shortdata[$i][13]  $shortdata[$i][3]) / ($shortdata[$i][13]) * 100,2);
edit*****
I'm still having trouble formatting the Score per min.
ASP original code.
Code: Select all
formatnumber(shortdata(i,3)/(shortdata(i,4)/60),3)
I can see its global score divided by time played(seconds) divided by 60.
but i cant get the right result.
Code: Select all
Method 1
number_format(($shortdata[$i][3]/$shortdata[$i][4])/60,3)
Code: Select all
Method 2
echo $shortdata[$i][3].'<br />';
echo $shortdata[$i][4].'<br />';
$tt = $shortdata[$i][4] / 60;
$tt/= $shortdata[$i][3];
echo number_format($tt,3).'<br />';
also what does the field cppm represent?
other then those 2 values i have the Print summary finished and I have made
a start on the big stats so everythings moving along well.
Thanks
Nos

 Comfortable with my sexuality
 Posts: 1408
 Joined: Fri Dec 02, 2005 7:57 am
 Location: Horse country
Re: Number Formatting
You missed a set of brackets. cppm is career points per minute, from memory.
My code :
round( x3 / (x4/60) , 3)
Your code :
round (x3/x4/60, 3)
You have to divide x4 by 60 to get it into minutes.
My code :
round( x3 / (x4/60) , 3)
Your code :
round (x3/x4/60, 3)
You have to divide x4 by 60 to get it into minutes.
Re: Number Formatting
Whoops, thanks for that piers dont know how i missed that. LOL
thanks
Nos
thanks
Nos