Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Implementation of qFuzzyCompare and zero values
Forum Updated to NodeBB v4.3 + New Features

Implementation of qFuzzyCompare and zero values

Scheduled Pinned Locked Moved C++ Gurus
3 Posts 3 Posters 4.3k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    j1elo
    wrote on 22 Jul 2013, 10:55 last edited by
    #1

    Hello all,
    I'm using qFuzzyCompare(a, b) in order to handle all floating point comparisons, but it has severe limitations when a or b may be zero.

    Somewhere in the docs it is recommended to add +1 to the values, but this is not a really useful suggestion because some of the values might be -1.0, resulting in 0.0 after the addition.

    So far, in each file which needs to perform floating point comparisons, I'm using the following macro:

    @
    #include <QtGlobal> // qMax, qMin, qFuzzyCompare
    #define qFuzzyCompare(a, b) (qFuzzyIsNull(a) && qFuzzyIsNull(b)) || qFuzzyCompare((a), (b))
    @

    But instead of ad-hoc workarounds, IMHO this caveat should be fixed straight in the implementation of the qFuzzyCompare() function. A really old bug report already exists: "QTBUG-16819":https://bugreports.qt-project.org/browse/QTBUG-16819 it is open but it seems that discussion ended on 2011 for some reason.

    Could anyone add a bit more on this subject?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 22 Jul 2013, 12:20 last edited by
      #2

      Hmm... I'm not familiar with this issue, but it does look like something that could be handled better by the library itself.

      You can post to the "Development mailing list":http://lists.qt-project.org/mailman/listinfo/development to start a discussion with Qt's engineers.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tonyorourke
        wrote on 28 Aug 2014, 12:07 last edited by
        #3

        My guess is the good folks at Qt aren't interested because the good folks at Qt don't use qFuzzyCompare themselves; instead, they favour a set of 'qFsk...' routines which you'll find here -

        C:\Qt3d\src\threed\geometry\qvector_utils_p.h

        (or somewhere like it, depending on where your Qt3d source code is)

        The routines you find there should solve your problems.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved