3 ! 13.7.53 INT(A [, KIND])
5 ! Description. Convert to integer type.
6 ! Class. Elemental function.
8 ! A shall be of type integer, real, or complex,
9 ! or a boz-literal-constant .
10 ! KIND (optional) shall be a scalar integer initialization expression.
12 ! Result Characteristics. Integer. If KIND is present, the kind type
13 ! parameter is that specified by the value of KIND; otherwise, the
14 ! kind type parameter is that of default integer type.
18 ! Case (1): If A is of type integer, INT (A) = A.
20 ! Case (2): If A is of type real, there are two cases:
21 ! (a) if |A| < 1, INT (A) has the value 0
22 ! (b) if |A| .ge. 1, INT (A) is the integer whose magnitude is the
23 ! largest integer that does not exceed the magnitude of A and
24 ! whose sign is the same as the sign of A.
26 ! Case (3): If A is of type complex, INT(A) = INT(REAL(A, KIND(A))).
28 ! Case (4): If A is a boz-literal-constant, it is treated as if it were
29 ! an int-literal-constant with a kind-param that specifies the
30 ! representation method with the largest decimal exponent range
31 ! supported by the processor.
33 ! Example. INT (3.7) has the value 3.
36 integer, parameter :: ik1 = selected_int_kind(2)
37 integer, parameter :: ik2 = selected_int_kind(4)
38 integer, parameter :: ik4 = selected_int_kind(9)
39 integer, parameter :: ik8 = selected_int_kind(18)
40 integer, parameter :: sp = selected_real_kind(6,30)
41 integer, parameter :: dp = selected_real_kind(15,300)
42 integer, parameter :: ck = kind('a')
64 if (i1 /= -3_ik1 .or. i2 /= -3_ik2) call abort
65 if (i4 /= -3_ik4 .or. i8 /= -3_ik8) call abort
71 if (i1 /= 5_ik1 .or. i2 /= 5_ik2) call abort
72 if (i4 /= 5_ik4 .or. i8 /= 5_ik8) call abort
78 if (i1 /= 10_ik1 .or. i2 /= 10_ik2) call abort
79 if (i4 /= 10_ik4 .or. i8 /= 10_ik8) call abort
88 if (i1 /= -3_ik1 .or. i2 /= -3_ik2) call abort
89 if (i4 /= -3_ik4 .or. i8 /= -3_ik8) call abort
96 if (i1 /= -3_ik1 .or. i2 /= -3_ik2) call abort
97 if (i4 /= -3_ik4 .or. i8 /= -3_ik8) call abort
106 if (i1 /= 0_ik1 .or. i2 /= 0_ik2) call abort
107 if (i4 /= 0_ik4 .or. i8 /= 0_ik8) call abort
114 if (i1 /= 0_ik1 .or. i2 /= 0_ik2) call abort
115 if (i4 /= 0_ik4 .or. i8 /= 0_ik8) call abort
119 c4 = (-3.7E-1_sp,3.7E-1_sp)
124 if (i1 /= 0_ik1 .or. i2 /= 0_ik2) call abort
125 if (i4 /= 0_ik4 .or. i8 /= 0_ik8) call abort
127 c8 = (-3.7E-1_dp,3.7E-1_dp)
132 if (i1 /= 0_ik1 .or. i2 /= 0_ik2) call abort
133 if (i4 /= 0_ik4 .or. i8 /= 0_ik8) call abort
135 c4 = (-3.7_sp,3.7_sp)
140 if (i1 /= -3_ik1 .or. i2 /= -3_ik2) call abort
141 if (i4 /= -3_ik4 .or. i8 /= -3_ik8) call abort
148 if (i1 /= 3_ik1 .or. i2 /= 3_ik2) call abort
149 if (i4 /= 3_ik4 .or. i8 /= 3_ik8) call abort
153 i1 = int(b'0011', ik1)
154 i2 = int(b'0011', ik2)
155 i4 = int(b'0011', ik4)
156 i8 = int(b'0011', ik8)
157 if (i1 /= 3_ik1 .or. i2 /= 3_ik2) call abort
158 if (i4 /= 3_ik4 .or. i8 /= 3_ik8) call abort
159 i1 = int(o'0011', ik1)
160 i2 = int(o'0011', ik2)
161 i4 = int(o'0011', ik4)
162 i8 = int(o'0011', ik8)
163 if (i1 /= 9_ik1 .or. i2 /= 9_ik2) call abort
164 if (i4 /= 9_ik4 .or. i8 /= 9_ik8) call abort
165 i1 = int(z'0011', ik1)
166 i2 = int(z'0011', ik2)
167 i4 = int(z'0011', ik4)
168 i8 = int(z'0011', ik8)
169 if (i1 /= 17_ik1 .or. i2 /= 17_ik2) call abort
170 if (i4 /= 17_ik4 .or. i8 /= 17_ik8) call abort
174 ! { dg-final { cleanup-modules "mykinds" } }