2 ! { dg-options "-std=gnu" }
4 ! 13.7.53 INT(A [, KIND])
6 ! Description. Convert to integer type.
7 ! Class. Elemental function.
9 ! A shall be of type integer, real, or complex,
10 ! or a boz-literal-constant .
11 ! KIND (optional) shall be a scalar integer initialization expression.
13 ! Result Characteristics. Integer. If KIND is present, the kind type
14 ! parameter is that specified by the value of KIND; otherwise, the
15 ! kind type parameter is that of default integer type.
19 ! Case (1): If A is of type integer, INT (A) = A.
21 ! Case (2): If A is of type real, there are two cases:
22 ! (a) if |A| < 1, INT (A) has the value 0
23 ! (b) if |A| .ge. 1, INT (A) is the integer whose magnitude is the
24 ! largest integer that does not exceed the magnitude of A and
25 ! whose sign is the same as the sign of A.
27 ! Case (3): If A is of type complex, INT(A) = INT(REAL(A, KIND(A))).
29 ! Case (4): If A is a boz-literal-constant, it is treated as if it were
30 ! an int-literal-constant with a kind-param that specifies the
31 ! representation method with the largest decimal exponent range
32 ! supported by the processor.
34 ! Example. INT (3.7) has the value 3.
37 integer, parameter :: ik1
= selected_int_kind(2)
38 integer, parameter :: ik2
= selected_int_kind(4)
39 integer, parameter :: ik4
= selected_int_kind(9)
40 integer, parameter :: ik8
= selected_int_kind(18)
41 integer, parameter :: sp
= selected_real_kind(6,30)
42 integer, parameter :: dp
= selected_real_kind(15,300)
43 integer, parameter :: ck
= kind('a')
65 if (i1
/= -3_ik1
.or
. i2
/= -3_ik2
) call abort
66 if (i4
/= -3_ik4
.or
. i8
/= -3_ik8
) call abort
72 if (i1
/= 5_ik1
.or
. i2
/= 5_ik2
) call abort
73 if (i4
/= 5_ik4
.or
. i8
/= 5_ik8
) call abort
79 if (i1
/= 10_ik1
.or
. i2
/= 10_ik2
) call abort
80 if (i4
/= 10_ik4
.or
. i8
/= 10_ik8
) call abort
89 if (i1
/= -3_ik1
.or
. i2
/= -3_ik2
) call abort
90 if (i4
/= -3_ik4
.or
. i8
/= -3_ik8
) call abort
97 if (i1
/= -3_ik1
.or
. i2
/= -3_ik2
) call abort
98 if (i4
/= -3_ik4
.or
. i8
/= -3_ik8
) call abort
107 if (i1
/= 0_ik1
.or
. i2
/= 0_ik2
) call abort
108 if (i4
/= 0_ik4
.or
. i8
/= 0_ik8
) call abort
115 if (i1
/= 0_ik1
.or
. i2
/= 0_ik2
) call abort
116 if (i4
/= 0_ik4
.or
. i8
/= 0_ik8
) call abort
120 c4
= (-3.7E-1_sp
,3.7E-1_sp
)
125 if (i1
/= 0_ik1
.or
. i2
/= 0_ik2
) call abort
126 if (i4
/= 0_ik4
.or
. i8
/= 0_ik8
) call abort
128 c8
= (-3.7E-1_dp
,3.7E-1_dp
)
133 if (i1
/= 0_ik1
.or
. i2
/= 0_ik2
) call abort
134 if (i4
/= 0_ik4
.or
. i8
/= 0_ik8
) call abort
136 c4
= (-3.7_sp
,3.7_sp
)
141 if (i1
/= -3_ik1
.or
. i2
/= -3_ik2
) call abort
142 if (i4
/= -3_ik4
.or
. i8
/= -3_ik8
) call abort
149 if (i1
/= 3_ik1
.or
. i2
/= 3_ik2
) call abort
150 if (i4
/= 3_ik4
.or
. i8
/= 3_ik8
) call abort
154 i1
= int(b
'0011', ik1
)
155 i2
= int(b
'0011', ik2
)
156 i4
= int(b
'0011', ik4
)
157 i8
= int(b
'0011', ik8
)
158 if (i1
/= 3_ik1
.or
. i2
/= 3_ik2
) call abort
159 if (i4
/= 3_ik4
.or
. i8
/= 3_ik8
) call abort
160 i1
= int(o
'0011', ik1
)
161 i2
= int(o
'0011', ik2
)
162 i4
= int(o
'0011', ik4
)
163 i8
= int(o
'0011', ik8
)
164 if (i1
/= 9_ik1
.or
. i2
/= 9_ik2
) call abort
165 if (i4
/= 9_ik4
.or
. i8
/= 9_ik8
) call abort
166 i1
= int(z
'0011', ik1
)
167 i2
= int(z
'0011', ik2
)
168 i4
= int(z
'0011', ik4
)
169 i8
= int(z
'0011', ik8
)
170 if (i1
/= 17_ik1
.or
. i2
/= 17_ik2
) call abort
171 if (i4
/= 17_ik4
.or
. i8
/= 17_ik8
) call abort
175 ! { dg-final { cleanup-modules "mykinds" } }