Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon May 18, 2009 3:45 am   

Simple question!
 
I'm attempting to find the average of some variables, I'm going about it like so

#math totalpercfail (((@totalnone+@totalfade+@totalblow)/@totalchant)*100)

The *100 is because I figured it may round up if it's below zero, but even then I'm not getting anything but 0.

Now I'm no algebraic genius, but I think that's the correct format for the equation I want done, and I searched a while to discover / was the symbol for division. Am I using the wrong command or something?
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Mon May 18, 2009 4:10 am   
 
Try add %float(@totalchant)
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Mon May 18, 2009 4:25 am   
 
hmm, well I don't see anything wrong with that but Cmud sometimes rounds things funny.

You might try: (((@totalnone+@totalfade+@totalblow)*100)/@totalchant) as your expression
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon May 18, 2009 4:43 am   
 
That did the trick, thanks alot.

So when looking for percentages I just have to multiply everything by 100 before hand :P
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon May 18, 2009 5:21 am   
 
Now, does anyone know how to force cmud to deal with things in the decimal places?
Reply with quote
Scirkhan
Apprentice


Joined: 14 Sep 2007
Posts: 167
Location: aztx

PostPosted: Mon May 18, 2009 7:39 am   
 
float?

adding .00 to all your numbers involving a non-whole number should work.
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon May 18, 2009 5:42 pm   
 
Changing the order of the equation so that it multiplied before diving worked.

I am dividing by variables, so where in the stage do I add .00? in the triggers that set the variables, or ((@myvar.00+@myvartoo.00)/100)?
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon May 18, 2009 5:48 pm   
 
Whoa, so setting all my triggers to define my variables by 1.00 works, but now when the math is done it rounds to about eight places. Anyone know a way to just make it to the hundredths place?
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Mon May 18, 2009 5:55 pm   
 
try formating the number after all your caculating is done see %format
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
Khana
Beginner


Joined: 26 Feb 2009
Posts: 27

PostPosted: Mon May 18, 2009 6:25 pm   
 
That did the trick, appreciate it.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net