| 1 |
! Program to test SIGN intrinsic |
| 2 |
program intrinsic_sign |
| 3 |
implicit none |
| 4 |
integer i, j |
| 5 |
real r, s |
| 6 |
|
| 7 |
i = 2 |
| 8 |
j = 3 |
| 9 |
if (sign (i, j) .ne. 2) STOP 1 |
| 10 |
i = 4 |
| 11 |
j = -5 |
| 12 |
if (sign (i, j) .ne. -4) STOP 2 |
| 13 |
i = -6 |
| 14 |
j = 7 |
| 15 |
if (sign (i, j) .ne. 6) STOP 3 |
| 16 |
i = -8 |
| 17 |
j = -9 |
| 18 |
if (sign (i, j) .ne. -8) STOP 4 |
| 19 |
r = 1 |
| 20 |
s = 2 |
| 21 |
if (sign (r, s) .ne. 1) STOP 5 |
| 22 |
r = 1 |
| 23 |
s = -2 |
| 24 |
if (sign (r, s) .ne. -1) STOP 6 |
| 25 |
s = 0 |
| 26 |
if (sign (r, s) .ne. 1) STOP 7 |
| 27 |
! Will fail on machines which cannot represent negative zero. |
| 28 |
s = -s ! Negative zero |
| 29 |
if (sign (r, s) .ne. -1) STOP 8 |
| 30 |
end program |
| 31 |
|