Home / ObjectScript Reference / ObjectScript Functions / $ZSQR

ObjectScript Reference
Previous section           Next section
InterSystems: The power behind what matters   

Returns the square root of a specified number.
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

Previous section           Next section
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-04-10 14:45:57