|
Gilbert Beginner
Joined: 10 Oct 2000 Posts: 11 Location: Germany
|
Posted: Fri Dec 28, 2001 6:33 pm
Want to have float... |
Hi,
it's possible to get a float and not a integer ?
i.e.
#math bla (3 / 2) = 2 (but i want to have 1.5)
greetings
Christian |
|
|
|
Acaila Apprentice
Joined: 30 Aug 2001 Posts: 187 Location: Netherlands
|
Posted: Fri Dec 28, 2001 7:16 pm |
The new beta version of zMUD (v6.24) supports floating point mathematics, earlier versions like 6.16 don't. Some people have created a few ways around this using more complicated calculations, but I can't remember what it was exactly.
Acaila |
|
|
|
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Fri Dec 28, 2001 10:07 pm |
For most applications, the workaround is assumed decimal points. Say you want to know the answer to 3 figures- multiply by 1000 before doing the division:
3/2 = (3000 / 2) (/1000) = 1500 (/1000)
You never perform the implicit division (/1000) at the end, you just 'keep it in mind' when figuring out what acceptable values are or doing more math on the result.
I think the most commonly seen application used to be representing numbers as percents- 2/3 doesn't give 66.6% using integer math, so you do 2000/3 = 666 and keep in mind that that's really 66.6%.
-Tarn |
|
|
|
Gilbert Beginner
Joined: 10 Oct 2000 Posts: 11 Location: Germany
|
Posted: Fri Dec 28, 2001 10:41 pm |
Hi,
i think the float() in 6.24 doesn't work....
#sh %float(3) -> Result: 3.0
#sh %float(3.1) -> Result: Error-Window 'Message '3.1'is not a valid floating point value'
#sh %float(3,1) -> Result: 3.0
#sh %isfloat(3) -> Result: 0
#sh %isfloat(3,1) -> Result: 0
#sh %isfloat(3.1) -> Result: Error-Window 'Message '3.1'is not a valid floating point value'
I want to get a percent-value like:
(exp * 100 / exp_for_next_level) = %
But i want (i wish for next year *ggggg*) to get a value like 34.12% ;)
greetings
Christian
PS: sorry for my bad english :( |
|
|
|
|
|