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
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sat Mar 02, 2002 5:12 am   

Floating Point Variables & Rounding
 
In the MUD I play, each character's total exp is calculated in what is called "worth". There is also a tax on this worth if you decide to reincarnate. I've made triggers to keep track of the tax percent and when it lowers, but the problem is that for some reason, if the tax is over 20m exp, it won't show correctly (gives a value of -3% or something similar. So, I changed in to using a floating point variable with the %float command. NOW, the tax is shown like this: 5.56522846221924 %. Kind of long. I was wondering if there was a way to make it rounded to just the whole number AND hundredths. Ex-

5.56522846221924 would be 5.57 (rounding up from the 5 thousandth.

Thank you for your time and any help you might shed on this.

Fat Tony
Reply with quote
Kru
Beginner


Joined: 14 Nov 2001
Posts: 28

PostPosted: Sat Mar 02, 2002 7:01 am   
 
This is cheese but here:

#FU {GiveMeaName} {%word("%1",1,".").%if(%right(%left(%word("%1",2,"."),2),1)>4,%eval(%left(%word("%1",2,"."),2)+1),%left(%word("%1",2,"."),2))}

usage: #SHOW @GiveMeaName(5.56522846221924)

:)
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Sat Mar 02, 2002 7:36 am   
 
That worked, thank you very much.

Fat Tony
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sat Mar 02, 2002 1:42 pm   
 
You might also want to look into the %format function. Example:
#SHOW %format(2,1.3265362323)

shows:
1.33

Kjata
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