十进制类型在Qt(C ++) [英] Decimal type in Qt (C++)

查看:132
本文介绍了十进制类型在Qt(C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Qt开发中使用的正确类型(或一般来说是C ++)的十进制运算,即<。code> System.Decimal struct in .Net? p>


  • Qt是否提供内置结构? (我在文档中找不到,但可能不知道在哪里查找。)

  • 是否有要使用的标准C ++库?


解决方案


在Qt中使用的正确类型
开发C ++在一般情况下)对于
的十进制算术,即
相当于
中的System.Decimal结构.Net?


C ++标准库和Qt都不具有等价于.NET中 System.Decimal 的任何数据类型。



< blockquote>

Qt提供了一个内置的struct? (I
在文档中找不到,但也许
不知道在哪里查找。)


否。


是否有一个标准的C ++库供
使用?


否。



但您可能需要查看 GNU多精度算术库



比上述图书馆更好的选择可能是 qdecimal 。它包含一个符合IEEE标准的十进制浮点数,这与.NET十进制非常相似(但不完全相同),以及利用Qt习语和惯例。


What is the correct type to use in Qt development (or C++ in general) for decimal arithmetic, i.e. the equivalent of System.Decimal struct in .Net?

  • Does Qt provide a built-in struct? (I can't find it in the docs, but maybe don't know where to look.)
  • Is there a "standard" C++ library to use?

解决方案

What is the correct type to use in Qt development (or C++ in general) for decimal arithmetic, i.e. the equivalent of System.Decimal struct in .Net?

Neither C++ standard library nor Qt has any data type equivalent to System.Decimal in .NET.

Does Qt provide a built-in struct? (I can't find it in the docs, but maybe don't know where to look.)

No.

Is there a "standard" C++ library to use?

No.

But you might want to have a look at the GNU Multiple Precision Arithmetic Library.

[EDIT:] A better choice than the above library might be qdecimal. It wraps an IEEE-compliant decimal float, which is very similar (but not exactly the same as) the .NET decimal, as well utilizing Qt idioms and practices.

这篇关于十进制类型在Qt(C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆