Compute the number of bits of a character variable.
use penf
print FI4P, bit_size('ab')
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | i |
Character variable whose number of bits must be computed. |
Number of bits of c.
elemental function bit_size_chr(i) result(bits) !< Compute the number of bits of a character variable. !< !<```fortran !< use penf !< print FI4P, bit_size('ab') !<``` !=> 16 <<< character(*), intent(IN) :: i !< Character variable whose number of bits must be computed. integer(I4P) :: bits !< Number of bits of c. integer(I1P) :: mold(1) !< "Molding" dummy variable for bits counting. bits = size(transfer(i, mold), dim=1, kind=I4P) * 8_I4P endfunction bit_size_chr