]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/fortran/doc/gfortran/intrinsic-procedures/btest.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / btest.rst
CommitLineData
c63539ff
ML
1..
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.
5
6.. _btest:
7
8.. index:: BTEST
9
10.. index:: BBTEST
11
12.. index:: BITEST
13
14.. index:: BJTEST
15
16.. index:: BKTEST
17
18.. index:: bits, testing
19
20BTEST --- Bit test function
21***************************
22
23.. function:: BTEST(I,POS)
24
25 ``BTEST(I,POS)`` returns logical ``.TRUE.`` if the bit at :samp:`{POS}`
26 in :samp:`{I}` is set. The counting of the bits starts at 0.
27
28 :param I:
29 The type shall be ``INTEGER``.
30
31 :param POS:
32 The type shall be ``INTEGER``.
33
34 :return:
35 The return value is of type ``LOGICAL``
36
37 Standard:
38 Fortran 90 and later, has overloads that are GNU extensions
39
40 Class:
41 Elemental function
42
43 Syntax:
44 .. code-block:: fortran
45
46 RESULT = BTEST(I, POS)
47
48 Example:
49 .. code-block:: fortran
50
51 program test_btest
52 integer :: i = 32768 + 1024 + 64
53 integer :: pos
54 logical :: bool
55 do pos=0,16
56 bool = btest(i, pos)
57 print *, pos, bool
58 end do
59 end program test_btest
60
61 Specific names:
62 .. list-table::
63 :header-rows: 1
64
65 * - Name
66 - Argument
67 - Return type
68 - Standard
69
70 * - ``BTEST(I,POS)``
71 - ``INTEGER I,POS``
72 - ``LOGICAL``
73 - Fortran 95 and later
74 * - ``BBTEST(I,POS)``
75 - ``INTEGER(1) I,POS``
76 - ``LOGICAL(1)``
77 - GNU extension
78 * - ``BITEST(I,POS)``
79 - ``INTEGER(2) I,POS``
80 - ``LOGICAL(2)``
81 - GNU extension
82 * - ``BJTEST(I,POS)``
83 - ``INTEGER(4) I,POS``
84 - ``LOGICAL(4)``
85 - GNU extension
86 * - ``BKTEST(I,POS)``
87 - ``INTEGER(8) I,POS``
88 - ``LOGICAL(8)``
3ed1b4ce 89 - GNU extension