[ Previous |
Next |
Contents |
Glossary |
Home |
Search ]

*AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 2*

## sqrt, sqrtl, or cbrt Subroutine

### Purpose

Computes square root and cube root functions.

### Libraries

IEEE Math Library (**libm.a**)

or System V Math Library (**libmsaa.a**)

### Syntax

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

**long double sqrtl (***x***)**
**long double ***x***;**

**double cbrt (***x***)**
**double ***x***;**

### Description

The **sqrt** subroutine, **sqrtl** subroutine, and **cbrt **subroutine compute the square root and cube root, respectively, of their parameters.

**Note:** |
Compile any routine that uses subroutines from the **libm.a** library with the **-lm** flag. To compile the **sqrt.c** file, for example, enter:
cc sqrt.c -lm |

### Parameters

*x* |
Specifies some double-precision floating-point value. |

### Return Values

The **sqrt **(-0.0) = -0.0.

The **sqrtl** (-0.0) = -0.0.

### 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**):

For the **sqrt** and the **sqrtl** subroutines, 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.

### Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

The **cbrt** subroutine is not part of the ANSI C Library.

### Related Information

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

Subroutines Overview
*AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs*.

128-Bit long double Floating-Point Format
*AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs*.

[ Previous |
Next |
Contents |
Glossary |
Home |
Search ]