User Tag List

Results 1 to 2 of 2

Thread: [Bug]Floating Point issues

  1. #1
    No Products Registered

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

    [Bug]Floating Point issues

    a floating point issue that's been around since MMF1.5:
    Code:
    Repeat while "Space" is pressed
    + Global Value A < 3.0
    --> Add to Global Value A: 0.2
    
    X Repeat while "Space" is pressed
    + Global Value A > 0.0
    --> Subtract from Global Value A: 0.2
    This code works fine for the addition, however, the subtraction gets weird. 2.8 to 0.2 works fine, but instead of giving 0 for the next operation, i get 5.55112e-17. obviously still above 0 so i'll finally get -0.2 as an answer. a similar thing happens with 0.1, even... most larger numbers like 0.25 and 0.5 behave correctly

    i know that computers tend have issues with representing floating points exactly, however if this can't be truly fixed, there should be a better solution than "multiply everything enough so you aren't using floats, check for (in)equalities, and divide afterward". Maybe an option for MMF to automatically truncate decimal values past a certain limit? I'd imagine that most games would only need 2 or 3 decimal places if they even needed them at all... most of MMF's floating point errors seem to be extremely small numbers that could easily be filtered out with a method like this

  2. #2
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    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)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    England
    Posts
    3,515
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)

    Re: [Bug]Floating Point issues

    Ah yes, I see what you mean. A workaround is to use global strings instead.

    Code:
    Repeat while "Space bar" is pressed
    + Compare two general values: Val(Global String A) < 3.0
    --> Set Global String A to Str$(Val(Global String A)+0.2)
    
    X Repeat while "Space bar" is pressed
    + Compare two general values: Val(Global String A) > 0.0
    --> Set Global String A to Str$(Val(Global String A)-0.2)
    .:::.Joshtek.:::.

Similar Threads

  1. [BUG] floating point rotation
    By SolarB in forum iOS Export Module Version 2.0
    Replies: 5
    Last Post: 2nd December 2012, 01:40 AM
  2. rotation using floating point
    By JimCarter in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 11th February 2010, 04:52 PM
  3. Floating Point Arrays?
    By Dines in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 1st January 2008, 11:00 PM
  4. Floating Point Numbers
    By killacam in forum The Games Factory 2 - Technical Support
    Replies: 1
    Last Post: 5th October 2006, 06:37 AM
  5. How to force floating point?
    By Pixalatio in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 7th July 2006, 04:15 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
  •