to_real_R16P Function

private elemental function to_real_R16P(self, kind) result(to_number)

Cast string to real (R16P).

 use penf
 type(string) :: astring
 real(R16P)   :: real_
 logical      :: test_passed(1)
 astring = '3.4e9'
 real_ = astring%to_number(kind=1._R16P)
 test_passed(1) = real_==3.4e9_R16P
 print '(L1)', all(test_passed)

Type Bound

string

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

The string.

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

Mold parameter for kind detection.

Return Value real(kind=R16P)

The number into the string.


Calls

proc~~to_real_r16p~~CallsGraph proc~to_real_r16p stringifor_string_t::string%to_real_R16P proc~is_real stringifor_string_t::string%is_real proc~to_real_r16p->proc~is_real

Contents

Source Code


Source Code

   elemental function to_real_R16P(self, kind) result(to_number)
   !< Cast string to real (R16P).
   !<
   !<```fortran
   !< use penf
   !< type(string) :: astring
   !< real(R16P)   :: real_
   !< logical      :: test_passed(1)
   !< astring = '3.4e9'
   !< real_ = astring%to_number(kind=1._R16P)
   !< test_passed(1) = real_==3.4e9_R16P
   !< print '(L1)', all(test_passed)
   !<```
   !=> T <<<
   class(string), intent(in) :: self      !< The string.
   real(R16P),    intent(in) :: kind      !< Mold parameter for kind detection.
   real(R16P)                :: to_number !< The number into the string.

   if (allocated(self%raw)) then
     if (self%is_real()) read(self%raw, *) to_number
   endif
   endfunction to_real_R16P