I want to change text into float number for calculation in Qt
float test = ui.tableWidget->item(0, 1)->text().replace(",", ".", Qt::CaseSensitive).toFloat();
when I type 2.86, actually I see test = 2.85999990
in debug. How can I receive correctly what i typed ?
I can use this for showing
qDebug() << QString::number( test, 'f', 2 );
But I want a value for calculation, not for showing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.