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