nint Interface

public interface nint

Contents


Module Procedures

private impure elemental function nint_s2v(chars)

NAME

  int(3f) - [M_strings:TYPE] overloads INT(3f) so it can handle character arguments
  (LICENSE:PD)

SYNOPSIS

impure elemental function int(string)

 character(len=*) :: string
 integer(kind=int32) :: int

DESCRIPTION

int(3f) returns an integer when given a numeric representation of a
numeric value. This overloads the INT(3f) intrinsic so that CHARACTER
arguments assumed to represent a numeric value may be input.

OPTIONS

   STRING  input string to be converted to an INT32 integer

RETURNS

   INT  integer represented by input string

EXAMPLE

Sample program:

  program demo_int
  use M_strings, only: int
  implicit none
  write(*,*)int('100'),int('20.4')
  write(*,*)'int still works',int(20.4)
  write(*,*)'elemental',&
  & int([character(len=23) :: '10','20.3','20.5','20.6'])
  end program demo_int

Results:

  >          100          20
  >  int still works          20
  >  elemental          10          20          20          20

AUTHOR

John S. Urban

LICENSE

Public Domain

NAME

  nint(3f) - [M_strings:TYPE] overloads NINT(3f) so it can handle character arguments
  (LICENSE:PD)

SYNOPSIS

impure elemental function nint(string)

 character(len=*) :: string
 integer          :: nint

DESCRIPTION

nint(3f) returns an integer when given a numeric representation of a
numeric value. This overloads the NINT(3f) intrinsic so that CHARACTER
arguments assumed to represent a numeric value may be input.

OPTIONS

   STRING  input string to be converted to an integer

RETURNS

   NINT  integer represented by input string

EXAMPLE

Sample program:

  program demo_nint
  use M_strings, only: nint
  implicit none
  write(*,*)nint('100'),nint('20.4')
  write(*,*)'nint still works',nint(20.4)
  write(*,*)'elemental',&
  & nint([character(len=23) :: '10','20.3','20.5','20.6'])
  end program demo_nint

Results:

  >          100          20
  >  nint still works          20
  >  elemental          10          20          21          21

AUTHOR

John S. Urban

LICENSE

Public Domain

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: chars

Return Value integer