C ++是否有一个代表Pi值的标准符号? [英] Does C++ have a standard symbol representing the value Pi?

查看:118
本文介绍了C ++是否有一个代表Pi值的标准符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将Pi的精确值精确到任意精度,但是直接将它作为

的标准功能可以很好地获得它。语言。我忽略了什么,或者它不存在?


ISO / IEC14882:2003(E)为我提供了这个:


模板< class T>复杂< T> log(const complex< T>& x);


" 4注意:分支切口沿负实轴。

5返回: x的复数自然(基数e)对数,在实际轴和间隔数学上无界限的范围内[-i

乘以pi,i沿着假想轴的时间pi。当x为负实数

数时,imag(log(x))为pi。


3.141592653589793238462643383279502884197169399375 1058209749445923078164062862 \

08998628034825342117067982148086513282306647093844 6095505822317253594081284811\

17450284102701938521105559644622948954930381964428 8109756659334461284756482337\

86783165271201909145648566923460348610454326648213 39360726024914127

-

STH

哈顿定律:只有一个不可侵犯的法律

KDevelop: http://www.kdevelop.org SuSE: http:/ /www.suse.com

Mozilla: http:// www.mozilla.org

解决方案

*" Steven T. Hatton" <苏****** @ setidava.kushan.aa> schriebt:


我可以将Pi的精确值精确到任意精度,但是直接将它作为

它不存在于C中(至少在1999年之前),所以它在C ++中不存在。


As您可以在< cmath>中找到非标准扩展名M_PI。


请参阅< url:http://www.eskimo.com/~scs/C-faq/ q14.8.html> ;.

ISO / IEC14882:2003(E)为我提供了这个:

模板< class T>复杂< T> log(const complex< T>& x);

" 4注意:分支切口沿负实轴。
5返回:复杂的自然(基数e)对数x,在沿着实轴在数学上无界的条带的范围内并且在沿着虚轴的间隔[-i
乘以pi,i乘以pi]的范围内。当x是一个负实
数,IMAG(日志(X))是圆周率"。

3.141592653589793238462643383279502884197169399375 1058209749445923078164062862\
08998628034825342117067982148086513282306647093844 6095505822317253594081284811\
17450284102701938521105559644622948954930381964428 8109756659334461284756482337 \\ /
86783165271201909145648566923460348610454326648213 39360726024914127




只有数学家才能有这个! ;-)


为什么不用acos?


顺便说一句,你在二十世纪后检查了数字吗? (我没有,

但怀疑那里有垃圾。)


-

答:因为它搞砸了人们通常阅读文字的顺序。

问:为什么顶级发布这么糟糕的事情?

A:热门发布。

问:usenet和电子邮件中最烦人的事情是什么?





pi是一个 invinite"数。如果你想在你的程序中使用pi,

你必须自己定义精度(取决于你的
要求)。看看分析1.


关于marbac


" Alf P. Steinbach" <人*** @ start.no>写了

*" Steven T. Hatton" <苏****** @ setidava.kushan.aa> schriebt:


我可以将Pi的精确值精确到任意精度,但是直接将它作为



它不存在于C中(至少在1999年之前),所以它在C ++中不存在。

作为非标准扩展,您可以在< cmath>中找到M_PI。

请参阅< url:http://www.eskimo.com/~scs/C -faq / q14.8.html> ;.

ISO / IEC14882:2003(E)为我提供了这个:

模板< class T>复杂< T> log(const complex< T>& x);

" 4注意:分支切口沿负实轴。
5返回:复杂的自然(基数e)对数x,在沿着实轴在数学上无界的条带的范围内并且在沿着虚轴的间隔[-i
乘以pi,i乘以pi]的范围内。当x是一个负实
数,IMAG(日志(X))是圆周率"。


3.141592653589793238462643383279502884197169399375 105820974944592307816406286208998628034825342117067982148086513282306647093844 609550582231725359408128481117450284102701938521105559644622948954930381964428 8109756659334461284756482337\ 86783165271201909145648566923460348610454326648213 39360726024914127


只有数学家可以有这个! ;-)

为什么不用acos?

顺便说一句,你在二十世纪后检查了数字吗? (我没有,但是怀疑那里有垃圾。)




数字很好,包括最后一次正确的舍入7.这有什么好处<在现实世界中,
确实会引起争议。


Claudio Puviani


I can get the accurate value of Pi to an arbitrary precision, but it would
be nice to have it directly and readily available as a standard feature of
the language. Have I overlooked something, or is it not there?

ISO/IEC14882:2003(E) offers me this:

template<class T> complex<T> log(const complex<T>& x);

"4 Notes: the branch cuts are along the negative real axis.
5 Returns: the complex natural (base e) logarithm of x, in the range of a
strip mathematically unbounded along the real axis and in the interval [-i
times pi, i times pi ] along the imaginary axis. When x is a negative real
number, imag(log(x)) is pi."

3.141592653589793238462643383279502884197169399375 1058209749445923078164062862\
08998628034825342117067982148086513282306647093844 6095505822317253594081284811\
17450284102701938521105559644622948954930381964428 8109756659334461284756482337\
86783165271201909145648566923460348610454326648213 39360726024914127
--
STH
Hatton''s Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org

解决方案

* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:


I can get the accurate value of Pi to an arbitrary precision, but it would
be nice to have it directly and readily available as a standard feature of
the language. Have I overlooked something, or is it not there?
It''s not there in C (at least pre 1999), so it''s not there in C++.

As a non-standard extension you might find M_PI in your <cmath>.

See <url: http://www.eskimo.com/~scs/C-faq/q14.8.html>.
ISO/IEC14882:2003(E) offers me this:

template<class T> complex<T> log(const complex<T>& x);

"4 Notes: the branch cuts are along the negative real axis.
5 Returns: the complex natural (base e) logarithm of x, in the range of a
strip mathematically unbounded along the real axis and in the interval [-i
times pi, i times pi ] along the imaginary axis. When x is a negative real
number, imag(log(x)) is pi."

3.141592653589793238462643383279502884197169399375 1058209749445923078164062862\
08998628034825342117067982148086513282306647093844 6095505822317253594081284811\
17450284102701938521105559644622948954930381964428 8109756659334461284756482337\
86783165271201909145648566923460348610454326648213 39360726024914127



Only a mathematician could have thunk of that! ;-)

Why not acos?

And btw., have you checked the digits after the twentieth? (I haven''t,
but suspect garbage there.)

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Hi,

pi is an "invinite" number. If you want do use pi within your program,
you have to define the precision yourself (depending on your
requirements). Have a look at analysis 1.

regards marbac


"Alf P. Steinbach" <al***@start.no> wrote

* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:


I can get the accurate value of Pi to an arbitrary precision, but it would
be nice to have it directly and readily available as a standard feature of
the language. Have I overlooked something, or is it not there?



It''s not there in C (at least pre 1999), so it''s not there in C++.

As a non-standard extension you might find M_PI in your <cmath>.

See <url: http://www.eskimo.com/~scs/C-faq/q14.8.html>.

ISO/IEC14882:2003(E) offers me this:

template<class T> complex<T> log(const complex<T>& x);

"4 Notes: the branch cuts are along the negative real axis.
5 Returns: the complex natural (base e) logarithm of x, in the range of a
strip mathematically unbounded along the real axis and in the interval [-i
times pi, i times pi ] along the imaginary axis. When x is a negative real
number, imag(log(x)) is pi."

3.141592653589793238462643383279502884197169399375 105820974944592307816406286208998628034825342117067982148086513282306647093844 609550582231725359408128481117450284102701938521105559644622948954930381964428 8109756659334461284756482337\ 86783165271201909145648566923460348610454326648213 39360726024914127



Only a mathematician could have thunk of that! ;-)

Why not acos?

And btw., have you checked the digits after the twentieth? (I haven''t,
but suspect garbage there.)



The digits are good, including proper rounding of the last 7. What good this
would do in the real world is certainly debatable.

Claudio Puviani


这篇关于C ++是否有一个代表Pi值的标准符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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