如何计算pi的值 [英] how to calculate value of pi

查看:76
本文介绍了如何计算pi的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编程世界很陌生。我遇到了问题,因此陷入了

。请指导我。


我正试图获得价值

(128 ^ 100)^ 2

我已经使用了long double类型但无济于事。

我甚至无法获得价值

2 ^ 128.

如何解决这个问题?

同样,我正在尝试开发一个程序,我们可以计算出我们所需小数点的PI值为
,但我陷入了困境。

如何在C中解决这些问题?

C为我们提供了哪些工具来计算这些值?

解决方案

Thomas写道:


我对编程世界很陌生。我遇到了问题,因此陷入了

。请指导我。


我正试图获得价值

(128 ^ 100)^ 2

我已经使用了long double类型但无济于事。

我甚至无法获得价值

2 ^ 128.

如何解决这个问题?

同样,我正在尝试开发一个程序,我们可以计算出我们所需小数点的PI值为
,但我陷入了困境。

如何在C中解决这些问题?

C为我们提供了哪些工具来计算这些值?



C语言不能直接提供这些东西。但请查看
www.snippets.org 了解一大堆有趣的内容。


-

Joe Wright

一切尽可能简单,但并不简单。

---阿尔伯特爱因斯坦---


" Thomas"写道:


我是编程世界的新手。我遇到了问题,因此陷入了

。请指导我。


我正试图获得价值

(128 ^ 100)^ 2

我用过长双号但无济于事。



这是一个非常大的数字,不是吗?使用科学计算器并记录

来估算价值。然后查看长双倍的数字范围。
处理。您可以编写一个小程序,并使用< limits.heto

中的值找出您的特定机器中的范围。


我甚至不能得到

2 ^ 128的价值。

如何解决这个问题?



发布你试过的代码。


同样,我试图开发一个程序我可以把PI的值计算到我们想要的小数点,但我陷入其中。

如何在C中解决这些问题?

C为我们提供了哪些工具来计算这些值?



C提供正常的算术运算符加,减,乘和

除以< math.h中的函数加上一些b / b
其他的东西。


有很多方法可以计算pi,其中一些非常差。我确定你可以在网上找到足够的线索让你忙碌几天和

天。基本上你做了一系列

某种值的数值估计..


该链接中的网站为初级程序员提供了一些很好的帮助。

http://en.wikipedia.org/wiki / Main_Page


托马斯说:


我很陌生编程世界。我遇到了问题,因此陷入了

。请指导我。


我正试图获得价值

(128 ^ 100)^ 2


27669029702758120146491942186874884129832195596687 593922941153328644\

61503706121889747295812490836130522939753216599929 386788554537297860\

72051766301814526769339210738412304501439841789615 580511966398183532\

32501575334232440224365258413261224549068647496733 893492858693838936\

01936689405612487962894280618800556342388396076741 350978743071524441 \

46728820186095678197423949799582894481473506157406 815975220112285819 \

60985268453376


I '使用了long double类型但无济于事。

我甚至无法获得价值

2 ^ 128。


340282366920938463463374607431768211456

如何这个问题是可以解决的?



编程。


同样,我试图开发一个程序,我们可以计算

PI的值到我们想要的小数点,但我陷入其中。


的#define PI 3.1415926535897932384626433


如果你需要更多的,它ain''t工程,即对于

肯定。


如何在C中解决这些问题?



使用编程,如果你感到懒惰[1],使用其他人的

编程。在网上查找bignums或Miracl或GMP。


C为我们提供了哪些工具来计算这些值?



+ - * /%=

[1]程序员的懒惰并不一定是坏事。


-

Richard Heathfield< http://www.cpax.org.uk>

电邮:-www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日


Hi, I''m pretty new to the programming world. I got stuck in the
following problem. Please guide me about it.

Well I''m trying to get the value of
(128^100)^2
I''ve used long double type but to no avail.
I even can''t get the value of
2^128.
How this problem can be solved?
Similarly, I was trying to develoop a program in hich we can calculate
the value of PI to our desired decimal point, but i got stuck in it.
How these sort of problems can be solved in C?
What tools C provides us to calculate such values?

解决方案

Thomas wrote:

Hi, I''m pretty new to the programming world. I got stuck in the
following problem. Please guide me about it.

Well I''m trying to get the value of
(128^100)^2
I''ve used long double type but to no avail.
I even can''t get the value of
2^128.
How this problem can be solved?
Similarly, I was trying to develoop a program in hich we can calculate
the value of PI to our desired decimal point, but i got stuck in it.
How these sort of problems can be solved in C?
What tools C provides us to calculate such values?

The C language doesn''t provide that stuff directly. But do check out
www.snippets.org for a whole bunch of interesting stuff.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---


"Thomas" wrote:

Hi, I''m pretty new to the programming world. I got stuck in the
following problem. Please guide me about it.

Well I''m trying to get the value of
(128^100)^2
I''ve used long double type but to no avail.

That''s a pretty big number, isn''t it? Use a scientific calculator and logs
to estimate the value. Then look at the range of numbers that long double
handles. You can write a little program and the values in <limits.heto
find out what the range is in your particular machine.

I even can''t get the value of
2^128.
How this problem can be solved?

Post the code you tried.

Similarly, I was trying to develoop a program in hich we can calculate
the value of PI to our desired decimal point, but i got stuck in it.
How these sort of problems can be solved in C?
What tools C provides us to calculate such values?

C provides the normal arithmetic operators add, subtract, multiply and
divide enhanced by the functions in <math.h Plus a few dribs and drabs of
other things.

There are many ways to compute pi, some of them spectacularly poor. I am
sure you can find enough clues on the Web to keep you occupied for days and
days. Essentially you do a numeric estimate of the value of a series of
some sort..

The site in the link offers some great help to a beginning programmer.

http://en.wikipedia.org/wiki/Main_Page


Thomas said:

Hi, I''m pretty new to the programming world. I got stuck in the
following problem. Please guide me about it.

Well I''m trying to get the value of
(128^100)^2

27669029702758120146491942186874884129832195596687 593922941153328644\
61503706121889747295812490836130522939753216599929 386788554537297860\
72051766301814526769339210738412304501439841789615 580511966398183532\
32501575334232440224365258413261224549068647496733 893492858693838936\
01936689405612487962894280618800556342388396076741 350978743071524441\
46728820186095678197423949799582894481473506157406 815975220112285819\
60985268453376

I''ve used long double type but to no avail.
I even can''t get the value of
2^128.

340282366920938463463374607431768211456

How this problem can be solved?

With programming.

Similarly, I was trying to develoop a program in hich we can calculate
the value of PI to our desired decimal point, but i got stuck in it.

#define PI 3.1415926535897932384626433

If you ever need more than that, it ain''t for engineering, that''s for
sure.

How these sort of problems can be solved in C?

Using programming and, if you''re feeling lazy[1], using other people''s
programming. Look up "bignums", or "Miracl", or "GMP", on the Web.

What tools C provides us to calculate such values?

+ - * / % =
[1] Laziness in a programmer isn''t necessarily a bad thing.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


这篇关于如何计算pi的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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