User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19

Thread: Cannot get percentage?

  1. #1
    No Products Registered

    Join Date
    Feb 2007
    Location
    Sydney, Australia
    Posts
    1,654
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cannot get percentage?

    I got the counter object and I want to find the percentage of a value. So for this I simply do the equation a/b*100.

    The problem is, whenever I do this the counter remains as 0...and it's not meant to! I even did this in my calculator and it worked normally, Try it yourself! Why doesn't it work with MMF2?

  2. #2
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export ModuleUnicode Add-on

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cannot get percentage?

    You have to force float calculations by including a number with a decimal point.

    Try a/b*100.0

  3. #3
    Forum Moderator

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Burfelt's Avatar
    Join Date
    Jul 2006
    Location
    Denmark
    Posts
    525
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Re: Cannot get percentage?

    Netninja is right, but you need to make sure MMF understands that the values are floating point values before the division occurs.

    Try ((a*1.0)/(b*1.0))*100

  4. #4
    No Products Registered

    Join Date
    Jun 2006
    Posts
    625
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cannot get percentage?

    just adding 0.0 at first should be enough.

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cannot get percentage?

    a*100.0/b is the simplest...

    the ".0" forces it to use decimal places in the calculation, and the ordering means you don't have to add any extra "*1.0" or "+0.0".

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Cannot get percentage?

    Taking this a bit farther... is there a way to show only two digits to the right of the decimal?

  7. #7
    No Products Registered

    Join Date
    Aug 2006
    Posts
    984
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cannot get percentage?

    floor(NUMBER * 100) / 100.0

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Cannot get percentage?

    Won't this simply drop the value's RIGHT of the decimal point?

  9. #9
    No Products Registered

    Join Date
    Aug 2006
    Posts
    984
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Cannot get percentage?

    Quote Originally Posted by Tuna
    Won't this simply drop the value's RIGHT of the decimal point?
    well unless i screwed something up:

    1.23456 -> 123.456 -> 123 -> 1.23

    so yes it technically does get rid of them but i don't think mmf has a printf/sprintf-like function

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Cannot get percentage?

    Thanks for your assistance xyzzy...

    I'm doing Floor(hits/tries)

    or more accurately

    set text to str$(floor(value("hits")*100.0/value("tries")))+"%"

    I was getting values with 5 decimal places to the right of the decimal without the floor function. With it, I'm getting whole percentages only.


Page 1 of 2 1 2 LastLast

Similar Threads

  1. How to get the percentage of two counters?
    By Corlen in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 4th April 2012, 06:09 PM
  2. Percentage of Counter
    By Jdsfrog in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 25th October 2008, 03:14 PM
  3. Percentage Question
    By scdlsam in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 22nd April 2007, 04:05 PM
  4. Percentage
    By dingdong in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 13th December 2006, 06:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •