User Tag List

Results 1 to 8 of 8

Thread: Math/Float Question

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator ProPatch Maker
    coreyschroeder's Avatar
    Join Date
    Apr 2014
    Location
    ATX
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Math/Float Question

    Hey,

    I'm working on a small program that has a couple global values that are floats.
    I need to isolate the number before the decimal from the numbers behind the decimal.

    The only solution that I've come up with is:
    Parse the float to a string, use Mid$ to isolate, parse the string back to a value..

    I'm curious if there is a way to handle such a task without having to parse the float to a string?

  2. #2
    Clicker

    Join Date
    Jul 2011
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    T̶r̶y̶ ̶r̶o̶u̶n̶d̶(̶)̶.̶

    Nevermind that. BossRighteous has a much better solution.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export Module

    Join Date
    Apr 2014
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    floor() would be better suited since it essentially drops anything past the decimal, round would alter the number upward if the decimal portion is >=.5

    Do you also need to grab the the decimal portion as a separate number?

  4. #4
    Clicker

    Join Date
    Jul 2011
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey, whaddya know?! I learned what floor() is today.

    I came back because I modified my original example to account for the rounding upward: I multiplied the number by 10 before rounding and than divided by 10. LOL! floor() is certainly a better way to go. Thanks, Boss!

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export Module

    Join Date
    Apr 2014
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is also a ceiling() which rounds up any decimal >.0

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator ProPatch Maker
    coreyschroeder's Avatar
    Join Date
    Apr 2014
    Location
    ATX
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you all for your comments!

    To clarify:

    I actually need to isolate and store both numbers separately.

    For example, lets say the Global Value is 4.7, I need the 4 and I need the 7.

    Thanks!

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export Module

    Join Date
    Apr 2014
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This really only works if you have a significant figure (number of decimal places of accuracy) in mind.

    Attached is an example that pulls the first portion into a counter, and also pulls the second portion up to a defined amount of digits.

    *10 would be 1 digit of decimal, *10000 would be 4 and so on

    You'll notice that the counter rounds up the first assignment, but the value traces out right in the debug panel as an actual value.

    decimal break.mfa

    Doh! In the Counter properties there is a significant figure checkbox, so check that and the rounding wont occur on assignment to the counter. Anyway, you get the idea.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator ProPatch Maker
    coreyschroeder's Avatar
    Join Date
    Apr 2014
    Location
    ATX
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    floor((X - Floor(x))*1000) is awesome.

    BossRighteous is a Boss... Watch out Rick Ross..

Similar Threads

  1. Float Value Question
    By coreyschroeder in forum Fusion 2.5
    Replies: 7
    Last Post: 25th April 2014, 01:49 AM
  2. Math formula question
    By FlinkGigitty in forum Multimedia Fusion 2 - Technical Support
    Replies: 43
    Last Post: 6th October 2010, 06:08 PM
  3. Math question
    By FlinkGigitty in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 15th September 2010, 01:21 PM
  4. Quick math question
    By LaraSoft in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 26th December 2007, 10:16 AM

Posting Permissions

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