Results 1 to 2 of 2

Thread: QPointF equality operator

  1. #1
    Join Date
    Sep 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QPointF equality operator

    Hi everyone,

    The QPointF equality function seems to take floating point inaccuracy into account, however I have been unable to find any documentation on how it does so (ie. what epsilon value / percentage error etc. is used). Can anyone tell me how it is done and what tolerance values are used?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QPointF equality operator

    src/corelib/global/qglobal.h:
    Qt Code:
    1. static inline bool qFuzzyCompare(double p1, double p2)
    2. {
    3. return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2)));
    4. }
    5.  
    6. static inline bool qFuzzyCompare(float p1, float p2)
    7. {
    8. return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2)));
    9. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.