Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
XonDK
Apprentice


Joined: 01 Dec 2006
Posts: 178

PostPosted: Fri Oct 01, 2010 3:43 pm   

[3.29b] Floating Point calculations randomly failing
 
I'm experiencing a weird bug in floating point calculations, I'm using it to calculate critical and give me some information on the % of occurance, however seemingly randomly, after working fine for quite a while, they just stop working and every calculation gives 0.00
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Oct 01, 2010 4:01 pm   
 
A good start would be to show the code you are using and an explanation of what values the inputs could assume. Not having any idea what your code looks like I'd suggest making sure all the parts of the equation are being recognized as a floating point value by forcing it with %float to recognize it as a floating point number.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Fri Oct 01, 2010 4:49 pm   
 
As ReedN mentioned, we can't do much without more details. But it sounds to me like one of your variables is getting converted to a string value somewhere along the line. And when CMUD evaluates a string variable in a numeric expression, it returns zero.
Reply with quote
XonDK
Apprentice


Joined: 01 Dec 2006
Posts: 178

PostPosted: Fri Oct 01, 2010 10:08 pm   
 
XML export of one of the alias' that fail

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<alias name="crits">
<value><![CDATA[#IF (%1=%null) {
#SAY %cr%ansi(15)+%repeat("-",60)+
#SAY %ansi(15)|%repeat(%char(32),8)Total mauls: %format("&7d",@totalmauls)%repeat(%char(32),32)|
#SAY %ansi(15)|%repeat(%char(32),7)Normal Crits: %format("&7d",@normcrit) - %format("&6f",%eval((%float(@normcrit)/(@normcrit+@stagcrit+@cruscrit+@muticrit+@annicrit))*100))~% of all Crits.%repeat(%char(32),8)|
#SAY %ansi(15)|%repeat(%char(32),3)Staggering Crits: %format("&7d",@stagcrit) - %format("&6f",%eval((%float(@stagcrit)/(@normcrit+@stagcrit+@cruscrit+@muticrit+@annicrit))*100))~% of all Crits.%repeat(%char(32),8)|
#SAY %ansi(15)|%repeat(%char(32),5)Crushing Crits: %format("&7d",@cruscrit) - %format("&6f",%eval((%float(@cruscrit)/(@normcrit+@stagcrit+@cruscrit+@muticrit+@annicrit))*100))~% of all Crits.%repeat(%char(32),8)|
#SAY %ansi(15)|%repeat(%char(32),3)Mutilating Crits: %format("&7d",@muticrit) - %format("&6f",%eval((%float(@muticrit)/(@normcrit+@stagcrit+@cruscrit+@muticrit+@annicrit))*100))~% of all Crits.%repeat(%char(32),8)|
#SAY %ansi(15)|%repeat(%char(32),1)Annihilating Crits. %format("&7d",@annicrit) - %format("&6f",%eval((%float(@annicrit)/(@normcrit+@stagcrit+@cruscrit+@muticrit+@annicrit))*100))~% of all Crits.%repeat(%char(32),8)|
#SAY %ansi(15)|%repeat(%char(32),10)Crit rate: %format("&6f",%eval((%float(@normcrit+@stagcrit+@cruscrit+@muticrit+@annicrit)/(@totalmauls))*100))~%%repeat(%char(32),32)|
#SAY %ansi(15)+%repeat("-",60)+} {#IF (%begins("reset",%1)) {#SAY %ansi(15)Critical status reset.;totalmauls=0;normcrit=0;stagcrit=0;cruscrit=0;muticrit=0;annicrit=0}}]]></value>
</alias>
</cmud>

----

and this is a very old alias, that's worked fine and works fine most of the time. Heck I think its from zmud actually
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Fri Oct 01, 2010 10:51 pm   
 
Try to get it to fail and then export the whole thing, including variables? Not sure that alias alone will help. Maybe just some variables to test it with.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Oct 01, 2010 11:27 pm   
 
Make this: (@normcrit+@stagcrit+@cruscrit+@muticrit+@annicrit))*100)

this: %float((@normcrit+@stagcrit+@cruscrit+@muticrit+@annicrit))*100))

Like I said in my first comment. Both need to by of type float.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Sat Oct 02, 2010 2:22 am   
 
Just changing the 100 to 100.0 will help make it floating point too. But if it's returning zeros, I still think somewhere else the variables are getting set to string values somehow. GeneralStonewall is correct that we really need to see all of the XML showing the variable values too.
Reply with quote
XonDK
Apprentice


Joined: 01 Dec 2006
Posts: 178

PostPosted: Sat Oct 02, 2010 5:27 pm   
 
just enter crits reset or anything else after crits to reset them all to 0 then just add a number to total mauls and normcrits, when floating points begin to fail it fails even when its 1 totalmauls and 1 normcrits, 'why' floating points begin to fail I have no idea, it seems to happen randomly, while my system is running in normal things that 'normally' don't have any problems running
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sun Oct 03, 2010 4:00 pm   
 
I've notice that some of my saved variables are being interpreted as strings instead of floating point values. I'm having to put %float around these to force them to a float type variable for my scripts to work.

It seems this is something that occurred during one of the 3.x beta versions.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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