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 |
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; }
Portability
|
POSIX |
Win32 |
ANSI C |
ANSI C++ |
sqrt |
+ |
+ |
+ |
+ |
sqrtl |
|
+ |
+ |
+ |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|