logo hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    Rounding Error for Object Positions on iPad Pro 11"

    Scheduled Pinned Locked Moved
    Non-Issue
    2
    3
    648
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DavioD
      Davio
      last edited by Davio

      I came across a rounding error in the iPad Pro 11" mode (with ratio 199:139).

      If an object is at the Y position Height/2
      And I try the if statement
      { if Obj.pos.y = height/2 }
      It turns out they are not equal

      This is because:
      The height/2 = 18.65625
      The obj.pos.y = 18.6563

      So it seems that the position of objects are rounded to the 4th digit.
      Is there anyway that you guys could make the precision better?
      Thank you!

      @Hamed @Murtaza

      1 Reply Last reply Reply Quote 0
      • DavioD
        Davio
        last edited by Davio

        iPad Model: iPad Pro 10.5" 2nd Generation
        iOS version: 12.1
        hyperPad Version: 1.22
        Description: Object's positions are rounded to the 4th digit automatically instead of saving exact position
        Steps to reproduce:
        0- Set aspect ratio to 199:139 (iPad Pro) in the editor
        1- Set an object's y position to height/2
        2- Create an if statement that says { if object.pos.y = height/2 }
        Additional info:
        One workaround is to round both values to the 4th digit and then do the if statement comparing the rounded values. However, since I have many if statements, making the app compatible for 199:139 devices will be tricky.

        1 Reply Last reply Reply Quote 0
        • HamedH
          Hamed Admin
          last edited by

          @davio said in Rounding Error for Object Positions on iPad Pro 11":

          1- Set an object's y position to height/2

          @Davio you really shouldn't be doing this because there will always be floating point rounding errors like this.

          If you really need to check positions like that, I suggest checking for a range of values eg. If y > height / 2 + 2 and If y < height / 2 - 2.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post