|
Medin Newbie
Joined: 11 Jan 2004 Posts: 2 Location: Sweden
|
Posted: 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. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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.
|
|
|
|
Medin Newbie
Joined: 11 Jan 2004 Posts: 2 Location: Sweden
|
Posted: 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? :) |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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. |
|
|
|
|
|