User Tag List

Results 1 to 8 of 8

Thread: Rounding down a 2 digit float to 1 digit?

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Rounding down a 2 digit float to 1 digit?

    I have a feeling this is a simple solution, but it totally is not clicking in my head at the moment.

    I am reducing a float value by half. I need the result to round down its float value. Example: 3.3 * 0.5 = 1.65 ---> I need this to round down to 1.6

    All the float values I use in this particular situation are only single digit (one digit to the right of the decimal), which is why I need the result of this operation to be a single digit.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I just put my two cents without analizing the problem.
    Multiply yor result by 10 into an integer value, and then divide into a float by 10.0.
    I dont know if it can work in fusion but is the first thing that come to my mind.

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)
    alexexhowl's Avatar
    Join Date
    Jan 2015
    Location
    RU, YKT
    Posts
    359
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mobichan View Post
    I have a feeling this is a simple solution, but it totally is not clicking in my head at the moment.

    I am reducing a float value by half. I need the result to round down its float value. Example: 3.3 * 0.5 = 1.65 ---> I need this to round down to 1.6

    All the float values I use in this particular situation are only single digit (one digit to the right of the decimal), which is why I need the result of this operation to be a single digit.

    here formula:
    FloatToString$(>Value<, >Number of digits<, >Number of digits after decimal point or -1< )

  4. #4
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys. That did the trick. I assume it is faster to do 10mbra1's method? Or is a number to string to number conversion cpu less intensive?

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you need to work only with numbers and no strig you can bypass the conversion using the floor function in one step

    floor(yourCalculus*10)/10.0

    I am not on the pc now but I think it will work, and I dont remember the corret syntax of the floor functikn in fusion but I am sure to have seen it somewhere.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I have a question, for your application a result of 1.63 and 1.68 is always 1.6 or the second one is 1.7?

  7. #7
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    I want to always round down. So 1.6X should always result in 1.6.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)

    Join Date
    Sep 2017
    Location
    Milano, Italy
    Posts
    130
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mobichan View Post
    I want to always round down. So 1.6X should always result in 1.6.
    Ok in this case the formula Floor(1.6xxx * 10)/10.0 is working fine, the problem using Floor is if you use negative number and want -1.6xxx = -1.6 you cant use the floor function because
    Floor(-1.6xxxxx *10)/10.0 = -1.7
    you need to use the Ceiling function for negative number
    Ceiling(-1.6xxxx *10)/10.0 = -1.6

    Now you have different options
    - You are sure to not use negative number so there is no problem
    - You want that -1.6xxxxx = -1.7 and also here no problem
    - You want -1.6xxxx = -1.6 you can split the rounding down in two part checking if the original number to round is positive or negative and use the correct function Floor/Ceiling depending on the sign of the number
    - You want -1.6xxxx = -1.6 you can try with the suggestion of alexexhowl using the string conversion

    The right way to do the thing depends only on how is designed your app.

Similar Threads

  1. problem with digit result
    By arthurh in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 27th September 2013, 02:26 PM
  2. Removing last digit
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 19th November 2012, 10:58 PM
  3. Single Digit to Double Digit
    By Mantis in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 9th December 2010, 12:10 AM
  4. digit problem
    By Herbert in forum File Archive
    Replies: 1
    Last Post: 13th February 2010, 10:04 AM
  5. Get a digit from a counter
    By Raylax in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 13th December 2008, 11:51 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
  •