|
fattony Apprentice
Joined: 27 Dec 2001 Posts: 105 Location: USA
|
Posted: 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 |
|
|
|
Kru Beginner
Joined: 14 Nov 2001 Posts: 28
|
Posted: 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)
:) |
|
|
|
fattony Apprentice
Joined: 27 Dec 2001 Posts: 105 Location: USA
|
Posted: Sat Mar 02, 2002 7:36 am |
That worked, thank you very much.
Fat Tony |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: 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 |
|
|
|
|
|
|
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
|
|