SQRT (Square Root)

Free-Form Syntax (not allowed - use the %SQRT built-in function)
Code Factor 1 Factor 2 Result Field Indicators
SQRT (H) Value Root

The SQRT operation derives the square root of the field named in factor 2. The square root of factor 2 is placed in the result field.

Factor 2 must be numeric, and can contain one of: an array, array element, field, figurative constant, literal, named constant, subfield, or table name.

The result field must be numeric, and can contain one of: an array, array element, subfield, or table element.

An entire array can be used in a SQRT operation if factor 2 and the result field contain array names.

The number of decimal positions in the result field can be either less than or greater than the number of decimal positions in factor 2. However, the result field should not have fewer than half the number of decimal positions in factor 2.

If the value of the factor 2 field is zero, the result field value is also zero. If the value of the factor 2 field is negative, the RPG IV exception/error handling routine receives control.

For further rules on the SQRT operation, see Arithmetic Operations.

See Figure 172 for an example of the SQRT operation.



[ Top of Page | Previous Page | Next Page | Contents | Index ]