Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 1 - The PowerPC Numerics Environment
Chapter 6 - Numeric Operations and Functions / Arithmetic Operations


sqrt

You can use the square root (sqrt) function to compute the square root of a real number.

double_t sqrt(double_t x);
x
Any positive floating-point number.
DESCRIPTION
sqrt(x) = SQRTx

EXCEPTIONS
When x is finite and nonzero, either the result of sqrt(x) is exact or it raises one of the following exceptions:

  • inexact (if the result must be rounded)
  • invalid (if x is negative)

SPECIAL CASES
Table 6-7 shows the results when the argument to the square root function is a zero, a NaN, or an Infinity, plus other special cases for the square root function. In this table, x is a finite, nonzero floating-point number.
Table 6-7 Special cases for floating-point square root
OperationResultExceptions raised
sqrt(x)forx0 NaNInvalid
sqrt(+0) +0None
sqrt(-0) -0 None
sqrt(NaN) NaNNone[9]
sqrt(+ ) + None
sqrt(- ) NaNInvalid


[9] If the NaN is a signaling NaN, the invalid exception is raised.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996