summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.f90
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.f90
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.f90')
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.f9087
1 files changed, 87 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.f90
new file mode 100644
index 000000000..6f934e591
--- /dev/null
+++ b/gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.f90
@@ -0,0 +1,87 @@
+!Program to test SET_EXPONENT intrinsic function.
+
+program test_set_exponent
+ call test_real4()
+ call test_real8()
+end
+
+subroutine test_real4()
+ real*4 x,y
+ integer*4 i,n
+ equivalence(x, i)
+
+ n = -148
+ x = 1024.0
+ y = set_exponent (x, n)
+ if ((y .ne. 0.0) .and. (exponent (y) .ne. n)) call abort()
+
+ n = 8
+ x = 1024.0
+ y = set_exponent (x, n)
+ if (exponent (y) .ne. n) call abort()
+
+ n = 128
+ i = 8388607
+ x = transfer (i, x) ! z'007fffff' Positive denormalized floating-point.
+ y = set_exponent (x, n)
+ if (exponent (y) .ne. n) call abort()
+
+ n = -148
+ x = -1024.0
+ y = set_exponent (x, n)
+ if ((y .ne. 0.0) .and. (exponent (y) .ne. n)) call abort()
+
+ n = 8
+ x = -1024.0
+ y = set_exponent (x, n)
+ if (y .ne. -128.0) call abort()
+ if (exponent (y) .ne. n) call abort()
+
+ n = 128
+ i = -2139095041
+ x = transfer (i, x) ! z'807fffff' Negative denormalized floating-point.
+ y = set_exponent (x, n)
+ if (exponent (y) .ne. n) call abort()
+
+end
+
+subroutine test_real8()
+ implicit none
+ real*8 x, y
+ integer*8 i, n
+ equivalence(x, i)
+
+ n = -1073
+ x = 1024.0_8
+ y = set_exponent (x, n)
+ if ((y .ne. 0.0_8) .and. (exponent (y) .ne. n)) call abort()
+
+ n = 8
+ x = 1024.0_8
+ y = set_exponent (x, n)
+ if (y .ne. 128.0) call abort()
+ if (exponent (y) .ne. n) call abort()
+
+ n = 1024
+ i = 4503599627370495_8
+ x = transfer (i, x) !z'000fffffffffffff' Positive denormalized floating-point.
+ y = set_exponent (x, n)
+ if (exponent (y) .ne. n) call abort()
+
+ n = -1073
+ x = -1024.0
+ y = set_exponent (x, n)
+ if ((y .ne. 0.0) .and. (exponent (y) .ne. n)) call abort()
+
+ n = 8
+ x = -1024.0
+ y = set_exponent (x, n)
+ if (y .ne. -128.0) call abort()
+ if (exponent (y) .ne. n) call abort()
+
+ n = 1024
+ i = -9218868437227405313_8
+ x = transfer (i, x)!z'800fffffffffffff' Negative denormalized floating-point.
+ y = set_exponent (x, n)
+ if (exponent (y) .ne. n) call abort()
+end