Convert real to string of bits.
@note Note It is assumed that R16P is represented by means of 128 bits, but this is not ensured in all architectures.
use penf
character(128) :: b
b = bstr(n=1._R16P)
print "(A)", b(17:)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R16P), | intent(in) | :: | n |
Real to be converted. |
Returned bit-string containing input number.
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