Convert bit-string to real.
use penf
print FR8P, bcton('0000000000000000000000000000000000000000000000001111000000111111', knd=1._R8P)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | bstr |
String containing input number. |
||
real(kind=R8P), | intent(in) | :: | knd |
Number kind. |
Number returned.
elemental function bctor_R8P(bstr, knd) result(n) !< Convert bit-string to real. !< !<```fortran !< use penf !< print FR8P, bcton('0000000000000000000000000000000000000000000000001111000000111111', knd=1._R8P) !<``` !=> 0.100000000000000E+001 <<< character(*), intent(in) :: bstr !< String containing input number. real(R8P), intent(in) :: knd !< Number kind. real(R8P) :: n !< Number returned. integer(I1P) :: buffer(8) !< Transfer buffer. read(bstr, '(8B8.8)') buffer n = transfer(buffer, n) endfunction bctor_R8P