File: example_bitsets_bit_count.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (26 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
program example_bit_count
  use stdlib_bitsets
  implicit none
  character(*), parameter :: &
    bits_0 = '0000000000000000000'
  type(bitset_64) :: set0
  type(bitset_large) :: set1
  logical, allocatable :: logi(:)
  
  call set0%from_string(bits_0)
  if (set0%bit_count() == 0) then
    write (*, *) "FROM_STRING interpreted "// &
      "BITS_0's value properly."
  end if
  call set0%set(5)
  if (set0%bit_count() == 1) then
    write (*, *) "BIT_COUNT interpreted SET0's value properly."
  end if
  
  allocate( logi(1000), source=.false.)
  logi(1::7) = .true.
  set1 = logi
  if (set1%bit_count() == count(logi)) then
    write (*, *) "BIT_COUNT interpreted SET1's value properly."
  end if
end program example_bit_count