Elemental Intrinsic Function (Generic): Derives the square root of its argument.
Syntax
Results:
The result type is the same as x. The result has a value equal to the square root of x. A result of type complex is the principal value, with the real part greater than or equal to zero. When the real part of the result is zero, the imaginary part is greater than or equal to zero.
Specific Name | Argument Type | Result Type |
---|---|---|
SQRT | REAL(4) | REAL(4) |
DSQRT | REAL(8) | REAL(8) |
QSQRT 1 | REAL(16) | REAL(16) |
CSQRT 2 | COMPLEX(4) | COMPLEX(4) |
CDSQRT 3 | COMPLEX(8) | COMPLEX(8) |
CQSQRT 1 | COMPLEX(16) | COMPLEX(16) |
1 VMS and U*X
2 The setting of compiler option /real_size can affect CSQRT. 3 This function can also be specified as ZSQRT. |
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
Examples
SQRT (16.0) has the value 4.0.
SQRT (3.0) has the value 1.732051.
The following shows another example:
! Calculate the hypotenuse of a right triangle
! from the lengths of the other two sides.
REAL sidea, sideb, hyp
sidea = 3.0
sideb = 4.0
hyp = SQRT (sidea**2 + sideb**2)
WRITE (*, 100) hyp
100 FORMAT (/ ' The hypotenuse is ', F10.3)
END