Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

$ZSQR (ObjectScript)

Returns the square root of a specified number.




Argument Description
n Any positive number, or zero. (The null string and nonnumeric string values are treated as a zero.) Can be specified as a value, a variable, or an expression.


$ZSQR returns the square root of n. It returns the square root of 1 as 1. It returns the square root of 0 and the square root of a null string ("") as 0. Specifying a negative number invokes an <ILLEGAL VALUE> error. You can use the absolute value function $ZABS to convert negative numbers to positive numbers.


The following example returns the square root of a user-supplied number.

   READ "Input number for square root: ",num
   IF num<0 { WRITE "ILLEGAL VALUE: no negative numbers" }
   ELSE { WRITE $ZSQR(num) }

Here are some specific examples:


returns 1.414213562373095049.


returns 1.772453850905516027.

See Also