Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R16P), | intent(in) | :: | n | Real to be converted. |
||
logical, | intent(in), | optional | :: | no_sign | Flag for leaving out the sign. |
|
logical, | intent(in), | optional | :: | compact | Flag for compacting string encoding. |
Returned string containing input number.
Convert real to string.
elemental function str_R16P(n, no_sign, compact) result(str)
!---------------------------------------------------------------------------------------------------------------------------------
!< Convert real to string.
!---------------------------------------------------------------------------------------------------------------------------------
real(R16P), intent(in) :: n !< Real to be converted.
logical, intent(in), optional :: no_sign !< Flag for leaving out the sign.
logical, intent(in), optional :: compact !< Flag for *compacting* string encoding.
character(DR16P) :: str !< Returned string containing input number.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(str, FR16P) n ! Casting of n to string.
if (n>0._R16P) str(1:1)='+' ! Prefixing plus if n>0.
if (present(no_sign)) str=str(2:) ! Leaving out the sign.
if (present(compact)) then
if (compact) call compact_real_string(string=str)
endif
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction str_R16P