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
Medin
Newbie


Joined: 11 Jan 2004
Posts: 2
Location: Sweden

PostPosted: Sun Jan 11, 2004 10:21 pm   

Decimals in variables
 
I have this issue with zmud, when I have an value on an
variable that is for exampl 1,0 and want to add 1,0
the variable makes that 1,01 (#add "variable" 1,0)
Should be 2,0 right?
If I add 1,0 again it becoms 1,011 and so on.
What am I doing wrong? If anyone know how to get around
this I appreciate feedback.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Jan 12, 2004 2:23 am   
 
1,0 (or 1.0) is a string, not a number. If you want to do floating point math, use the #MATH command.
Reply with quote
Medin
Newbie


Joined: 11 Jan 2004
Posts: 2
Location: Sweden

PostPosted: Mon Jan 12, 2004 3:28 am   
 
Ok, but want to use the #MATH to count the percent from two values from variables
#MATH bla (@blo/@bli)*100
This will not work unless I use decimals, I do not know why.
And "counting" in variables ain't possible?
What to do? :)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Jan 12, 2004 9:14 am   
 
zMUD uses integer math by default. It only changes to floating point math when specifically told to by something such as the %float function or when it is necessary because one or more of the values are decimals.

You don't need to use floating point math to calculate percentages. The percentage formula will work just fine with integers by simply doing the multiplication before the division.
#MATH bla (@blo * 100)/@bli

"Counting" is certainly possible. Use integers.
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