The Daily Click ::. Forums ::. Klik Coding Help ::. MMF 1.5 ,(Out dated and underated yo), Counter Value Caculations Issue
 

Post Reply  Post Oekaki 
 

Posted By Message

Billybobjoe198



Registered
  12/01/2007
Points
  221
8th October, 2010 at 04:23:28 -

I'm trying to make a counter display the percent that X is of Y.

So I do, 100 - (((Y - X) / Y) * 100)
Lets give an example.
y = 7400
x = 600
100 - (((7400 - 600) / 7400) * 100)
100 - (((6800) / 7400) *100)
100 - (0.919 * 100)
100 - 91.9
8.1

Right?

Well how come when I put that into MMF it gives me 0 when X = 0. And 100 when X = anything else?
Is it just a flaw with the default counter object or is there something I'm doing wrong?

For reference, here's the code I'm putting in.
Always -> Set Counter -> 100 - ( ( ( value( "Y" ) - value( "X" ) ) / value( "Y" ) ) * 100 )


Edited by Billybobjoe198

 
n/a

Billybobjoe198



Registered
  12/01/2007
Points
  221
8th October, 2010 at 05:04:37 -

Seems actually after making a separate application that it will only figure to the nearest 100%, Anyone know of a way to make it actually work?

For a download:
http://www.mediafire.com/?47q1dc7b9d6xf4b

 
n/a

nim



Registered
  17/05/2002
Points
  7234
8th October, 2010 at 07:04:30 -


Originally Posted by Billybobjoe198

Always -> Set Counter -> 100 - ( ( ( value( "Y" ) - value( "X" ) ) / value( "Y" ) ) * 100 )


You need a decimal point somewhere to force (remind) MMF to give the result as a floating point.

Try:
Always -> Set Counter -> 100-( (value( "Y" -value( "X" ))/(value( "Y" )*1.0))*100) 


 
//

Billybobjoe198



Registered
  12/01/2007
Points
  221
8th October, 2010 at 07:24:13 -

When I just do 1.0 when I click okay on the dialog it removes the decimal,
When I do something like

Always -> Set Counter -> 100-( (value( "Y" -value( "X" ))/(value( "Y" )*1.0))*100.001) 

I get
X = 0, Z = 0.000000000000099921312
X > 0, Z = 100

Edit:
I added *0.1*10 to it after the first value Y and it seems to be working, only thing is when both values are 0 it comes out to "1e+009"
But deviding by 0 might be the issue there
Thanks man.

 100 - ( ( ( ( value( "Y" ) * 0.1 * 10 ) - value( "X" ) ) / value( "Y" ) * 1 ) * 100 )


Edited by Billybobjoe198

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
8th October, 2010 at 08:47:28 -

try adding 0.0 to it after the calculation. see if that works.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
8th October, 2010 at 13:26:21 -

I don't know where you got that crazy formula!
Just say:

(X * 100) / Y

That should also fix the decimal point problem, as the division is done last.

 
n/a

Billybobjoe198



Registered
  12/01/2007
Points
  221
8th October, 2010 at 17:27:13 -


Originally Posted by Sketchy
I don't know where you got that crazy formula!
Just say:

(X * 100) / Y



Lol, Yeah I don't know what I was thinking, I realized that when I woke up this morning. I find the opposite percent just to find the opposite of the opposite.

Edit:
When I use yours it only carries to the 2nd decimal, when I use my original it carries for the 4th decimal, no idea why.

Also, it's working now fully, thanks guys.

Image

Edited by Billybobjoe198

 
n/a
   

Post Reply



 



Advertisement

Worth A Click