digit_I8 Function

private elemental function digit_I8(n) result(digit)

Arguments

TypeIntentOptionalAttributesName
integer(kind=I8P), intent(in) :: n

Return Value integer(kind=I4P)


Called by

proc~~digit_i8~4~~CalledByGraph proc~digit_i8~4 digit_I8 interface~digit~4 digit interface~digit~4->proc~digit_i8~4

Contents

Source Code


Source Code

   elemental function digit_I8(n) result(digit)
   !< Compute the number of digits in decimal base of the input integer.
   !<
   !<```fortran
   !< use penf
   !< print FI4P, digit(100_I8P)
   !<```
   !=> 3 <<<
   integer(I8P), intent(in) :: n     !< Input integer.
   character(DI8P)          :: str   !< Returned string containing input number plus padding zeros.
   integer(I4P)             :: digit !< Number of digits.

   write(str, FI8P) abs(n)        ! Casting of n to string.
   digit = len_trim(adjustl(str)) ! Calculating the digits number of n.
   endfunction digit_I8