bstr_R16P Function

private elemental function bstr_R16P(n) result(bstr)

Arguments

TypeIntentOptionalAttributesName
real(kind=R16P), intent(in) :: n

Return Value character(len=128)


Contents

Source Code


Source Code

   elemental function bstr_R16P(n) result(bstr)
   !< Convert real to string of bits.
   !<
   !< @note It is assumed that R16P is represented by means of 128 bits, but this is not ensured in all architectures.
   !<
   !<```fortran
   !< use penf
   !< character(128) :: b
   !< b = bstr(n=1._R16P)
   !< print "(A)", b(17:)
   !<```
   !=> 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111100111111 <<<
   real(R16P), intent(in) :: n          !< Real to be converted.
   character(128)         :: bstr       !< Returned bit-string containing input number.
   integer(I1P)           :: buffer(16) !< Transfer buffer.

   buffer = transfer(n, buffer)
   write(bstr, '(16B8.8)') buffer
   endfunction bstr_R16P