DEV C ++中的准确性问题 [英] Problem with accuracy in DEV C++
问题描述
在下面的代码中
main()
{
double x;
for(x = 0.0; x <= 1; x = x + 0.05)
{
printf(" x =%6.3f \ n",x) ;
}
}
我收到的数字从0到0.950。 1不包括在内。据我所知,它是一个准确性问题,但我该如何解决呢?
In the following code
main()
{
double x;
for (x=0.0;x<=1;x=x+0.05)
{
printf("x=%6.3f \n",x);
}
}
I receive numbers from 0 to 0.950. 1 is not included. I understand that it
is an accuracy problem but how can I solve it ?
推荐答案
Hatzigiannakis Nikos说:
Hatzigiannakis Nikos said:
在以下代码中
main()
{
双x;
for(x = 0.0; x <= 1; x = x + 0.05)
{
printf(" x =%6.3f \ n",x);
}
}
我收到的数字从0到0.950。 1不包括在内。我明白了
是准确性问题,但我该如何解决呢?
In the following code
main()
{
double x;
for (x=0.0;x<=1;x=x+0.05)
{
printf("x=%6.3f \n",x);
}
}
I receive numbers from 0 to 0.950. 1 is not included. I understand that
it
is an accuracy problem but how can I solve it ?
for(x = 0.0; x <= 1.04; x = x + 0.05)
-
Richard Heathfield< http://www.cpax.org.uk>
电子邮件:-http:// www。 + rjh @
谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>
Usenet是一个奇怪的放置" - dmr 1999年7月29日
for (x = 0.0; x <= 1.04; x = x + 0.05)
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Hatzigiannakis Nikos写道:
Hatzigiannakis Nikos wrote:
在以下代码中
In the following code
main()
{
double x;
for(x = 0.0 ; x< = 1; x = x + 0.05)
{
printf(" x =%6.3f \ n",x);
}
}
main()
{
double x;
for (x=0.0;x<=1;x=x+0.05)
{
printf("x=%6.3f \n",x);
}
}
我收到的数字从0到0.950。 1不包括在内。我明白它是b $ b是准确性问题,但我该如何解决呢?
I receive numbers from 0 to 0.950. 1 is not included. I understand that it
is an accuracy problem but how can I solve it ?
#include< stdio.h / * note * /
int main(void)/ * note * /
{
int i;
for(i = 0; i< = 20; i ++)
printf(" x =%6.3f \ n",x / 20。);
返回0; / *注意* /
}
#include <stdio.h/* note */
int main(void) /* note */
{
int i;
for (i = 0; i <= 20; i++)
printf("x=%6.3f\n", x/20.);
return 0; /* note */
}
好的谢谢,但我希望trere是另一种更科学的方式!
>
? 理查德希思菲尔德 < rj*@see.sig.invalid ?????? ??? ??????
新闻:E4 ****************************** @ bt。 com ...
OK thanks but I hope that trere is an other more scientific way !
? "Richard Heathfield" <rj*@see.sig.invalid?????? ??? ??????
news:E4******************************@bt.com...
Hatzigiannakis Nikos说:
Hatzigiannakis Nikos said:
>在以下代码中
main()
{
double x;
for(x = 0.0; x <= 1; x = x + 0.05)
printf (x =%6.3f \ n,x);
}
我收到的数字从0到0.950。 1不包括在内。我明白
它是准确性问题,但我该如何解决呢?
>In the following code
main()
{
double x;
for (x=0.0;x<=1;x=x+0.05)
{
printf("x=%6.3f \n",x);
}
}
I receive numbers from 0 to 0.950. 1 is not included. I understand that
it
is an accuracy problem but how can I solve it ?
for(x = 0.0; x <= 1.04; x = x + 0.05)
-
Richard Heathfield< http://www.cpax.org.uk>
电子邮件:-http:// www。 + rjh @
谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>
Usenet是一个奇怪的放置" - 1999年7月29日dmr
for (x = 0.0; x <= 1.04; x = x + 0.05)
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
这篇关于DEV C ++中的准确性问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!