为什么在C ++ 11标准中没有常量pi的定义? [英] Why is there no definition of the constant pi in the C++11 standard?

查看:140
本文介绍了为什么在C ++ 11标准中没有常量pi的定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感到很烦,我必须使用宏 _USE_MATH_DEFINES 才能将pi的值添加到程序中。或者,我需要自己在自己的标头之一中定义它。或者我必须使用boost等。

I find it quiet annoying that I have to use the macro _USE_MATH_DEFINES in order to get the value of pi into my program. Or I need to define it myself in one of my own headers. Or I have to use boost and all that.

这让我很烦,因为没有标准的c ++标头以可移植的方式定义该常量。像pi这样的数学常数不在c ++标准中有什么特殊原因吗?

It just annoys me, that there isn't a standard c++ header defining that constant in a portable way. Is there any particular reason that math constants like pi are not in the c++ standard? Could it be in one of the next versions of the standard?

推荐答案

我认为它不是标准化的,因为它并不是真正的主要标准。关心。我真的没有发现仅编写#define或const静态变量,或仅使用可能需要的一堆数学常量制作标头的麻烦。在尝试改进语言时,构想该标准的人实际上并没有想到。

I would assume its not standardized because its not really a major concern. I really do not see any hassle in just writing down a #define or const static, or just making a header with a bunch of math constants you may need. Its not really anything anyone composing the standard has on his mind while trying to improve the language.

这篇关于为什么在C ++ 11标准中没有常量pi的定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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