User Tag List

Results 1 to 6 of 6

Thread: [Bug v257-20] Decimal addition/comparison problem

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Bug v257-20] Decimal addition/comparison problem

    I doubt this is something new in the latest beta, but thought I'd share it here anyway.

    Seems there's some problems when comparing decimal values.

    I've attached a simple file to show the problem.

    Looks like it's similar to this post:
    http://community.clickteam.com/threads/66111-Decimal-comparison-not-returning-true

    Would appreciate a workaround that handled more general cases correctly every time (other than not using decimals in the first place!)
    Attached files Attached files

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestion, SilentBob92PL.
    This works for the 3 tests in my example file. Unfortunately, not so good for more general values, eg If I want to start at 0.2, decrease by 0.05 each time and stop at when <=0, I get:

    0.15
    0.1
    0.05
    1.38778e-17
    -0.05

    Similar problems with other subtraction values, eg 0.1, 0.2
    In fact subtractiosn (or negative increments) seem much worse than adding for getting these kind of problem values.

    I guess it's just better to use integers for such stuff and divide by 100.0 later?

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    This is weird, I'm wondering if this is what's breaking my platform engine (based on Nifflas' one). Nifflas' own platform engine seems broken now too. Moving left seems to now move the character to the right, and sometimes he shoots across the screen. Also the jump is broken now.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DistantJ - I doubt it's related, since this happened before Beta257-22 and gives same results as before after installing this Beta.

  5. #5
    Clicker Fusion 2.5 DeveloperInstall Creator Pro

    Join Date
    Sep 2006
    Posts
    517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Usually it's recommended to avoid comparing directly float number with another float number but instead to check if the difference between the two float number is under a specific threshold.

    It has nothing to do with MMF but it's just due to the way float number are encoded and handled on computers.

    Have a look to http://www.parashift.com/c++-faq/flo...int-arith.html

  6. #6
    Clicker Fusion 2.5Android Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AftPeakTank's Avatar
    Join Date
    Apr 2013
    Location
    Greece
    Posts
    399
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Nice one ouly!

Similar Threads

  1. Addition problem
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 21st December 2011, 08:29 PM
  2. Decimal comparison not returning true
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 29th August 2011, 02:10 AM
  3. rounding decimal problem
    By arfa in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 6th December 2010, 02:14 PM
  4. I have a problem with decimal numbers
    By daniele in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 9th February 2009, 11:35 PM
  5. Decimal problem (minimap)
    By Jarzka in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 3rd July 2008, 04:56 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
  •