Convert bit-string to real.
use penf
print FR16P, bcton('00000000000000000000000000000000000000000000000000000000000000000000000000000'//&
'000000000000000000000000000000000001111111100111111', knd=1._R16P)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | bstr |
String containing input number. |
||
real(kind=R16P), | intent(in) | :: | knd |
Number kind. |
Number returned.
elemental function bctor_R16P(bstr, knd) result(n) !< Convert bit-string to real. !< !<```fortran !< use penf !< print FR16P, bcton('00000000000000000000000000000000000000000000000000000000000000000000000000000'//& !< '000000000000000000000000000000000001111111100111111', knd=1._R16P) !<``` !=> 0.100000000000000000000000000000000E+0001 <<< character(*), intent(in) :: bstr !< String containing input number. real(R16P), intent(in) :: knd !< Number kind. real(R16P) :: n !< Number returned. integer(I1P) :: buffer(16) !< Transfer buffer. read(bstr, '(16B8.8)') buffer n = transfer(buffer, n) endfunction bctor_R16P