主题:sqrt()语句的用法??哪个能给说明一下 啊?
			
 gulihulu
				 [专家分:0]  发布于 2006-05-10 20:57:00							
			哪个呢个感详细告诉sqrt()语句的用法??在我的程序里面,我用到的是sqrt(z),我把z定义为int型,错误说明是,sqrt:DOMAIN error ,我把z定义为float型,错误提示是:floating point overflow .Process stopped.请问哪个知道原因啊?
请速告诉!!!
拜谢!!
						
					 
		
			
回复列表 (共5个回复)
		
								
				沙发
				
					
rudolf [专家分:440]  发布于 2006-05-11 08:36:00				
				Header File
math.h 
Category
Math Routines
Prototype
double sqrt(double x);
long double sqrtl(long double x);
Description
Calculates the positive square root.
sqrt calculates the positive square root of the argument x.
sqrtl is the long double version; it takes a long double argument and returns a long double result. Error handling for these functions can be modified through the functions _matherr and _matherrl.
Return Value
On success, sqrt and sqrtl return the value calculated, the square root of x. If x is real and positive, the result is positive. If x is real and negative, the global variable errno is set to
EDOM    Domain error
/* sqrt example */
#include <math.h>
#include <stdio.h>
int main(void)
{
   double x = 4.0, result;
   result = sqrt(x);
   printf("The square root of %lf is %lf\n", x, result);
   return 0;
}
							 
						
				板凳
				
					
gulihulu [专家分:0]  发布于 2006-05-11 14:55:00				
				你能不能对你说的进行解释一下 啊?
							 
						
				3 楼
				
					
rudolf [专家分:440]  发布于 2006-05-11 15:55:00				
				传入的参数和返回值都是 double 类型或 都是long double类型
							 
						
				4 楼
				
					
tieqiaosan [专家分:90]  发布于 2006-05-12 20:04:00				
				1楼的是从帮助文档里边之间copy下来的吗?呵呵,不要笑我灌水哦。
							 
						
				5 楼
				
					
rudolf [专家分:440]  发布于 2006-05-13 11:14:00				
				没错,是COPY来的,只是想告诉LZ,这类简单的问题只需要看看帮助就什么都明白了。
然而
							 
									
			
我来回复