Something weird



  • When I run case 1, the console output is "True";
    But when I run case 2, the console output is "False"

    I can't figure it out, somebody help me plz

    ====== Case 1 =========
    QVector <int> av;
    int max = 54;

    av.append(9);
    av.append(6);

    if(av.at(0) * av.at(1) == max)
    qDebug("True");
    else
    qDebug("False");

    ====== Case 2: =========
    QVector <double> av;
    double max = 0.54;

    av.append(0.9);
    av.append(0.6);

    if(av.at(0) * av.at(1) == max)
    qDebug("True");
    else
    qDebug("False");


  • Qt Champions 2017

    Hi
    try to do
    qDebug() << av.at(0) * av.at(1);

    It works here but i guess its random.
    http://floating-point-gui.de/

    alt text


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.