|
fattony Apprentice
Joined: 27 Dec 2001 Posts: 105 Location: USA
|
Posted: Sun Jun 16, 2002 5:33 pm
Rounding numbers |
I have a rate checking alias that shows me how much exp/min I make. This is most commonly shown in 1000's (k) like 15k, 40k, etc. My variables all work fine and store the correct info, except the rate when divided by 1000. It automatically uses the thousand place.
Ex-
-=EXP RATE=- Since Jun 16 9:07 am
------------------------------------------
Exp Gained - 87600
Minutes - 19
Rate - 4810 {4k/min}
Should be rounded up to 5k/min. Tried turning the rate variable in to a floating point, but it is doing the same thing (ex- 4.0 instead of 4.8).
Any idea what I can do to fix this?
Fat Tony |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Jun 16, 2002 7:18 pm |
Since you talk about turning the variable into a floating point number, I'm going to assume that you are using a beta version that has floating point number support. If so, this should really go into the beta forum. Anyway, you need to make at least one of the operands a floating point number for the result to be a floating point number, otherwise, integer divison is performed and and any fractions are cut off. So, you would need to do:
#VAR rateInK %eval(%float(@rate) / 1000)
instead of:
#VAR rateInK %eval(@rate / 1000)
Kjata |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Jun 16, 2002 11:30 pm |
What you have now is presumably something like,
#VAR krate {%eval(@rate/1000)}
which rounds down. To round off, you'll need to do a bit more figuring
#VAR krate {%eval((@rate/1000)+((@rate1000)/500))}
This should work on the public version or the beta version.
LightBulb
Senior Member |
|
|
|
|
|
|
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
|
|