2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. index:: SELECTED_INT_KIND, integer kind, kind, integer
10 SELECTED_INT_KIND --- Choose integer kind
11 *****************************************
13 .. function:: SELECTED_INT_KIND(R)
15 ``SELECTED_INT_KIND(R)`` return the kind value of the smallest integer
16 type that can represent all values ranging from -10^R (exclusive)
17 to 10^R (exclusive). If there is no integer kind that accommodates
18 this range, ``SELECTED_INT_KIND`` returns -1.
21 Shall be a scalar and of type ``INTEGER``.
27 Transformational function
30 .. code-block:: fortran
32 RESULT = SELECTED_INT_KIND(R)
35 .. code-block:: fortran
37 program large_integers
38 integer,parameter :: k5 = selected_int_kind(5)
39 integer,parameter :: k15 = selected_int_kind(15)
40 integer(kind=k5) :: i5
41 integer(kind=k15) :: i15
43 print *, huge(i5), huge(i15)
45 ! The following inequalities are always true
46 print *, huge(i5) >= 10_k5**5-1
47 print *, huge(i15) >= 10_k15**15-1
48 end program large_integers