Convert bit-string to real.
use penf
print FR4P, bcton('00000000000000001000000000111111', knd=1._R4P)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | bstr |
String containing input number. |
||
real(kind=R4P), | intent(in) | :: | knd |
Number kind. |
Number returned.
elemental function bctor_R4P(bstr, knd) result(n) !< Convert bit-string to real. !< !<```fortran !< use penf !< print FR4P, bcton('00000000000000001000000000111111', knd=1._R4P) !<``` !=> 0.100000E+01 <<< character(*), intent(in) :: bstr !< String containing input number. real(R4P), intent(in) :: knd !< Number kind. real(R4P) :: n !< Number returned. integer(I1P) :: buffer(4) !< Transfer buffer. read(bstr, '(4B8.8)') buffer n = transfer(buffer, n) endfunction bctor_R4P