<IBITS Example Program>
Program ibits_example
Use Iso_Fortran_Env, Only:int8
Integer(int8), Parameter :: x = Int(B'11100101', int8)
Integer :: i
Do i=0, Bit_Size(1_int8)-2
Print 1, i, i+1, x, Ibits()
1 Format(1X, 'Bits ', I0, '-', I0, ' of ', B8.8, ' = ', B2.2)
End Do
End Program
■ Execution Results
Bits 0-1 of 11100101 = 01 Bits 1-2 of 11100101 = 10 Bits 2-3 of 11100101 = 01 Bits 3-4 of 11100101 = 00 Bits 4-5 of 11100101 = 10 Bits 5-6 of 11100101 = 11 Bits 6-7 of 11100101 = 11