Visible to Intel only — GUID: GUID-19931AA4-2B66-4D3B-8A60-B849D494E5FA
Visible to Intel only — GUID: GUID-19931AA4-2B66-4D3B-8A60-B849D494E5FA
SQRT
Elemental Intrinsic Function (Generic): Produces the square root of its argument.
result = SQRT (x)
x |
(Input) must be of type real or complex. If x is type real, its value must be greater than or equal to zero. |
The result type and kind are 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 of the result has the same sign as the imaginary part of x , even if the imaginary part of x is a negative real zero.
Specific Name |
Argument Type |
Result Type |
---|---|---|
SQRT |
REAL(4) |
REAL(4) |
DSQRT |
REAL(8) |
REAL(8) |
QSQRT |
REAL(16) |
REAL(16) |
CSQRT 1 |
COMPLEX(4) |
COMPLEX(4) |
CDSQRT2 |
COMPLEX(8) |
COMPLEX(8) |
CQSQRT |
COMPLEX(16) |
COMPLEX(16) |
1The setting of compiler options specifying real size can affect CSQRT. 2This function can also be specified as ZSQRT. |
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