[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 2

sqrt, sqrtf, or sqrtl Subroutine

Purpose

Computes the square root.

Syntax


#include <math.h>
double sqrt ( x)
double x;

float sqrtf (x)
float x;

long double sqrtl (x)
long double x;

Description

The sqrt, sqrtf, and sqrtl subroutines compute the square root of the x parameter.

An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

Parameters

x Specifies some double-precision floating-point value.

Return Values

Upon successful completion, the sqrtf subroutine returns the square root of x.

For finite values of x < -0, a domain error occurs, and a NaN is returned.

If x is NaN, a NaN is returned.

If x is ±0 or +Inf, x is returned.

If x is -Inf, a domain error shall occur, and a NaN is returned.

Error Codes

When using libm.a (-lm):

For the sqrt subroutine, if the value of x is negative, a NaNQ is returned and the errno global variable is set to a EDOM value.

When using libmsaa.a (-lmsaa):

If the value of x is negative, a 0 is returned and the errno global variable is set to a EDOM value. A message indicating a DOMAIN error is printed on the standard error output.

These error-handling procedures may be changed with the matherr subroutine when using the libmsaa.a (-lmsaa) library.

Related Information

The exp, expm1, log, log10, log1p, or pow subroutine.

feclearexcept Subroutine, fetestexcept Subroutine, and class, _class, finite, isnan, or unordered Subroutines in AIX 5L Version 5.2 Technical Reference: Base Operating System and Extensions Volume 1.

math.h in AIX 5L Version 5.2 Files Reference.

Subroutines Overview AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

128-Bit long double Floating-Point Format AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]