qstring转double精度
时间: 2024-02-03 07:04:43 浏览: 150
qt数据类型转换
3星 · 编辑精心推荐
回答: 当将QString转换为double时,精度不会丢失。实际上,问题可能出现在使用qDebug打印时。qDebug对于double类型只显示6位数字。如果想要打印所有数字,可以使用qSetRealNumberPrecision函数来设置精度。例如,可以使用以下代码来打印更高精度的double值:
QString val = "123.456789";
qDebug() << qSetRealNumberPrecision(10) << val.toDouble(); \[3\]
#### 引用[.reference_title]
- *1* [QString 转double,double转QString 中的小数点问题](https://blog.csdn.net/m0_46577050/article/details/124683035)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [QString和double互相转化的意外问题](https://blog.csdn.net/qq_34305316/article/details/102759553)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [qt QString转Double只显示6位数字的问题(精度丢失)](https://blog.csdn.net/weixin_43246170/article/details/126783741)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文