在VS2005下求cos( 90 )double dcos = cos( 3.1415926 / 180.0 * 90 );为什么返回的值是个奇怪的值。
但输出时却是正确的,结果为0.000;printf( "%lf", dcos );如果程序中要用cos的返回值,对于这种情况,通常的处理方案是什么。
但输出时却是正确的,结果为0.000;printf( "%lf", dcos );如果程序中要用cos的返回值,对于这种情况,通常的处理方案是什么。
double sincos( double angle )
{
const double PI = 3.14159265358579;
double dsin = sin( PI / 180.0 * angle );
double dcos = cos( PI / 180.0 * angle );
return dsin * dcos;
}
没有实做,不要大造声势。
strcpy还不是有问题么。
弄清楚cos(PI/16200) = ?? 还是cos(PI/2)哦?
#include <math.h>void main( void )
{
double pi = 3.1415926535;
double x, y; x = pi / 2;
y = sin( x );
printf( "sin( %f ) = %f\n", x, y ); y = sinh( x );
printf( "sinh( %f ) = %f\n",x, y );
y = cos( x );
// y = 4.4896592169761591e-011
//y *= 1000000000.0f;
//y = 0.044897;
printf( "cos( %f ) = %f\n", x, y ); y = cosh( x );
printf( "cosh( %f ) = %f\n",x, y );
}上面的cos会返回注释处的值,对于精度相当高的工艺,下面的乘法运算造成的小数,会导致事故。
sinh( 1.570796 ) = 2.301299
cos( 1.570796 ) = 0.000000
cosh( 1.570796 ) = 2.509178
Press any key to continue
你的代码我再VC6下的控制台程序测试的结果使这个。