int_width Function

private pure function int_width(i)

Number of characters of i as text, with any sign.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i

the number

Return Value integer


Source Code

pure integer function int_width(i)
    !! Number of characters of `i` as text, with any sign.
    integer, intent(in) :: i    !! the number
    integer :: n

    n = i
    int_width = merge(2, 1, i < 0)
    do
        n = n/10
        if (n == 0) exit
        int_width = int_width + 1
    end do
end function int_width