Convert bit-string to integer.
use penf
print FI1P, bcton('00000001', knd=1_I1P)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | bstr |
String containing input number. |
||
integer(kind=I1P), | intent(in) | :: | knd |
Number kind. |
Number returned.
elemental function bctoi_I1P(bstr, knd) result(n) !< Convert bit-string to integer. !< !<```fortran !< use penf !< print FI1P, bcton('00000001', knd=1_I1P) !<``` !=> 1 <<< character(*), intent(in) :: bstr !< String containing input number. integer(I1P), intent(in) :: knd !< Number kind. integer(I1P) :: n !< Number returned. read(bstr,'(B'//trim(str(bit_size(knd), .true.))//'.'//trim(str(bit_size(knd), .true.))//')') n endfunction bctoi_I1P