Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4P), | intent(in) | :: | n | Input integer. |
Number of digits.
Compute the number of digits in decimal base of the input integer.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=DI4P), | public | :: | str | Returned string containing input number plus padding zeros. |
elemental function digit_I4(n) result(digit)
!---------------------------------------------------------------------------------------------------------------------------------
!< Compute the number of digits in decimal base of the input integer.
!---------------------------------------------------------------------------------------------------------------------------------
integer(I4P), intent(in) :: n !< Input integer.
character(DI4P) :: str !< Returned string containing input number plus padding zeros.
integer(I4P) :: digit !< Number of digits.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
write(str, FI4P) abs(n) ! Casting of n to string.
digit = len_trim(adjustl(str)) ! Calculating the digits number of n.
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction digit_I4