bctor_R16P Function

private elemental function bctor_R16P(bstr, knd) result(n)

Arguments

TypeIntentOptionalAttributesName
character, intent(in) :: bstr
real(kind=R16P), intent(in) :: knd

Return Value real(kind=R16P)


Contents

Source Code


Source Code

   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