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


Joined: 26 Nov 2001
Posts: 1
Location: Finland

PostPosted: Mon Nov 26, 2001 7:18 pm   

How can I get decimals?
 
So, I'd really like to get decimals with #math or other zmud functions.

Example:

#math test ((360/100)*100)
Now it only gives value of 0.

Is there any way to get decimals in zmud?
Reply with quote
Darker
GURU


Joined: 24 Sep 2000
Posts: 1237
Location: USA

PostPosted: Mon Nov 26, 2001 7:22 pm   
 
Version 6.22 (in beta) adds new floating point math functions.



zMUD 6 Online Help: All the power you'll ever need.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Nov 26, 2001 11:57 pm   
 
quote:

So, I'd really like to get decimals with #math or other zmud functions.

Example:

#math test ((360/100)*100)
Now it only gives value of 0.

Is there any way to get decimals in zmud?



If you don't have 6.22, you'll have to assemble the "decimal number" manually. If you're looking for a floating-point number get ready for a serious headache. If you know you will always need X decimal places, you can simply use whole numbers and then insert the decimal point where needed.

li'l shmoe of Dragon's Gate MUD
Reply with quote
cingulli
Wanderer


Joined: 30 Aug 2001
Posts: 53
Location: Finland

PostPosted: Thu Nov 29, 2001 2:30 pm   
 
How ever, if ya still need something for 6.16, ya can use this of mine

#ALIAS percent {#IF (%2=0) {#var %2 00.00} {
#var percent %eval(((%1 * 100) / %2))
#var decimal %eval(((%1 * 100) %2)*100/%2)
#IF (%len(@percent)=1) {#var percent 0@percent}
#IF (%len(@decimal)=1) {#var decimal @decimal~0}
#var %3 {@percent~.@decimal}}}

it works like this

#var paska 45
#var kusi 90
#var paskakusi %null

'percent @paska @kusi paskakusi'
alias 45 / 90 50.00

Put @-character before the first two variables and dont put @ before the third variable.
This will write the answer to paskakusi. U can use this everywhere, in other aliases, triggers etc.
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