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