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


Joined: 03 Apr 2005
Posts: 3

PostPosted: Sun Apr 03, 2005 9:22 am   

problems with decimal numbers
 
im trying to monitor my stam use per round

here is an example of two rounds

ST[31.95%]
ST[30.52%]

here is my trigger

ST~[(%d)~.(%d)~%~]

the problem i am having is the decimal number, im not sure how to put a decimal value number into a variable then find the difference from the previous value. If anyone has any ideas on this id be thankful.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Apr 03, 2005 9:44 am   
 
Just combine them

ST~[(%d)~.(%d)~%~]

stvar=%1.%2
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
MaaQ
Newbie


Joined: 03 Apr 2005
Posts: 3

PostPosted: Sun Apr 03, 2005 10:51 am   Thanks
 
Thanks, that seems so simple im sorry to trouble you.
I am having a small problem though.
Why does my stamdiff variable go out so many decimal places

#VAR stam %5.%6
#MATH stamdiff (@stamp - @stam)
#VAR stam
#VAR stamp
#VAR stamdiff
#VAR stamp %5.%6

Variable: stam 71.14
Variable: stamp 71.95
Variable: stamdiff 0.80999755859375
Reply with quote
Vodoc
Apprentice


Joined: 11 Apr 2003
Posts: 119
Location: Sweden

PostPosted: Sun Apr 03, 2005 12:49 pm   
 
Use
Code:
%left(@stamdiff, 4)
to format the outcome to in this case "0.80". If you want it to round off properly will you have to make a function that checks the fifth letter and act on it.

Edit: Oh, and to answer your question of "Why?". The computer sees it as a "double" (data type) and calculates the answer, doubles ain't very precise though and thus the odd answer.
Reply with quote
MaaQ
Newbie


Joined: 03 Apr 2005
Posts: 3

PostPosted: Sun Apr 03, 2005 3:29 pm   Thanks for the help
 
thanks alot
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Apr 04, 2005 3:01 am   
 
There's a built-in function that normalizes a decimal number. You might wish to look into using that instead of %left().
_________________
EDIT: I didn't like my old signature
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