Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-45378

Dodgy arithmetic in fixed1616ToReal()

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 5.5.0
    • 5.5.0 Alpha
    • QPA: X11/XCB
    • None

    Description

      Whilst examining the XCB code, I noticed the following:

      qxcbconnection_xi2.cpp
      static inline qreal fixed1616ToReal(FP1616 val)
      {
          return (qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF;
      }
      

      Whilst this is an improvement over an earlier version that used 0xFF, I think this is wrong unless FP1616 has extremely unconventional semantics (such that e.g. 1.FFFF == 2.0000). I think a more plausible definition is simply

      qxcbconnection_xi2.cpp
      static inline qreal fixed1616ToReal(FP1616 val)
      {
          return qreal(val) / 0x1000;
      }
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              srutledg Shawn Rutledge
              tms13 Toby Speight
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes