Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, July 2007
while we are at QCOMPARE...


Message 1 in thread

... I had a rather peculiar incident with it today:

float d1 = 0.1f;
float d2 = 0.2f;
float a = 0.3f;
const float b = 0.4f;
float p = 0.5f;
b1i->qblas_srotmg(&d1,  &d2, &a, b, &p);
qDebug() << b;
QCOMPARE(b, 0.400000f);

where the method is void qblas_srotmg(float* d1,  float*  d2, float*  a, const 
float  b, float*  p), and this gives the quite surprising

QDEBUG : test::srotmg() 0.4
FAIL!  : test::srotmg() Compared floats are not the same (fuzzy compare)
   Actual (b): 0.375
   Expected (0.400000f): 0.4

Puzzling. Any ideas what might be causing this ? Watching the qCompare code 
does not give any easy explanations.

gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Qt 4.3.0 (debian lenny binary build, libqt4-* = 4.3.0-2+b1)

--
 [ signature omitted ]