QT 十六进制与浮点数相互转换
程序员文章站
2024-03-17 19:29:28
...
浮点数转十六进制
QString strFloat = ui.float_six1->text();
float f = strFloat.toFloat();
int i = *((int *)&f);
QString float_str = QString("%1").arg(i, 4, 16, QLatin1Char('0'));
ui.float_six2->setText(float_str );
十六进制转浮点数
QString strHex = ui.six_float1->text();
int c = strHex.toInt(nullptr, 16);
float d = *(float*)&c;
QString radiation = QString("%1").arg(d);
ui.six_float2->setText(radiation);
上一篇: 10进制和30进制的转换