bstr_R4P Function

private elemental function bstr_R4P(n) result(bstr)

Convert real to string of bits.

@note Note It is assumed that R4P is represented by means of 32 bits, but this is not ensured in all architectures.

 use penf
 print "(A)", bstr(n=1._R4P)

Arguments

Type IntentOptional Attributes Name
real(kind=R4P), intent(in) :: n

Real to be converted.

Return Value character(len=32)

Returned bit-string containing input number.


Called by

proc~~bstr_r4p~~CalledByGraph proc~bstr_r4p bstr_R4P interface~bstr bstr interface~bstr->proc~bstr_r4p program~volatile_doctest~115 volatile_doctest program~volatile_doctest~115->interface~bstr program~volatile_doctest~146 volatile_doctest program~volatile_doctest~146->interface~bstr program~volatile_doctest~181 volatile_doctest program~volatile_doctest~181->interface~bstr program~volatile_doctest~25 volatile_doctest program~volatile_doctest~25->interface~bstr program~volatile_doctest~52 volatile_doctest program~volatile_doctest~52->interface~bstr program~volatile_doctest~65 volatile_doctest program~volatile_doctest~65->interface~bstr program~volatile_doctest~78 volatile_doctest program~volatile_doctest~78->interface~bstr

Source Code

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

   buffer = transfer(n, buffer)
   write(bstr, '(4B8.8)') buffer
   endfunction bstr_R4P