User Tag List

Results 1 to 6 of 6

Thread: Round value to decimals?

  1. #1
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Question Round value to decimals?

    I am trying to round a number to two decimals. So for example 2.453156 should be 2.45
    I have tried round() but that only rounds completely so the number above becomes 2
    Anyone know?

  2. #2
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    FloatToString$(>Value<, >Number of digits<, >Number of digits after decimal point or -1< )

    Convert it to string and back to text!

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    I tried with a counter, set counter to: FloatToString$(2.3432, 5, 2)
    But i get an expression error? "Enter a numeric expression"

    O i see you have to actually convert it to a real string and then to number, thanks : )

  4. #4
    Clicker Fusion 2.5 Developer
    PBarwick's Avatar
    Join Date
    Jul 2014
    Posts
    390
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    As you've probably found, that function returns a string, so you would need to wrap the whole expression with Val() to convert it back to a number.

    Alternatively, you could multiply the original value by 100, then use Round() then divide it by 100.0

  5. #5
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Oh you can use Val() to do it on the fly? That's cool, gotta give it a go. Thanks for the heads up.

  6. #6
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,237
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PBarwick View Post
    As you've probably found, that function returns a string, so you would need to wrap the whole expression with Val() to convert it back to a number.

    Alternatively, you could multiply the original value by 100, then use Round() then divide it by 100.0

    Interesting method, will try that to! J3sseM:s way worked, but if you don't need to involve a string or alterable string that is useful!

Similar Threads

  1. how to round to nearest 25
    By rubes in forum Fusion 2.5
    Replies: 3
    Last Post: 3rd September 2014, 11:32 AM
  2. Round function ...how to?
    By Blue66 in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 26th April 2011, 10:22 AM
  3. How does MMF2 round floats?
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 13th August 2009, 06:11 PM
  4. creating a round meter fill up
    By GameDesigner in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 1st February 2008, 12:46 AM
  5. Round Value - Question
    By Jellyhead365 in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 5th January 2008, 04:19 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
  •