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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
mrkelley
Beginner


Joined: 15 Aug 2006
Posts: 14

PostPosted: Fri Sep 29, 2006 9:33 pm   

Making a variable do math from other variables
 
Title kinda says it all, could really use help here.

I'm trying to make Var1 = the divided sum of Var2 and Var 3.

The following code isn't working.

Code:
#VAR Var1 %eval( @Var2/@Var3)
#VAR Var1 (%eval( @Var2/@Var3))
#MATH Var1 (@Var2/@Var3)


Also, this will result in a decimal type number less than 1 (which may be my problem). Therefor I'd like to show 0.00 (in truth i'm just looking for a percentage)

Any help, please?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Sep 29, 2006 10:06 pm   
 
Math is generally done as integer math. The use of floating point values is often less precise then properly handled integer methods. You should multiply first then divide. Finally %insert the decimal point in the correct place just when displaying.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
mrkelley
Beginner


Joined: 15 Aug 2006
Posts: 14

PostPosted: Fri Sep 29, 2006 10:09 pm   
 
That makes very little sense to me. an example please?
Reply with quote
mrkelley
Beginner


Joined: 15 Aug 2006
Posts: 14

PostPosted: Fri Sep 29, 2006 10:17 pm   
 
Actually disregard. it works perfectly now. thank you.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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