count_digits_integer Interface

public interface count_digits_integer

Counts the number of digits of an integer, including the - sign in case it is a negative value.

Syntax

 n = count_digits_integer(i)

Where:

  • i: Integer number whose digits are to be counted

It returns the number of digits of the input number, including the - sign in case it is a negative value.

Example

The following program prints the number of digits of some integer numbers:

 PROGRAM count_digits_integerExample
    USE FU_Numbers, ONLY: count_digits_integer
    IMPLICIT NONE
    WRITE(*,*) count_digits_integer(1234)
    WRITE(*,*) count_digits_integer(-1234)
 END PROGRAM count_digits_integerExample

Contents


Module Procedures

private pure function count_digits_integer_i8(i) result(num_digits)

Arguments

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

Integer number whose digits are to be counted.

Return Value integer(kind=i8)

The number of digits of the input number.

private pure function count_digits_integer_i16(i) result(num_digits)

Arguments

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

Integer number whose digits are to be counted.

Return Value integer(kind=i16)

The number of digits of the input number.

private pure function count_digits_integer_i32(i) result(num_digits)

Arguments

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

Integer number whose digits are to be counted.

Return Value integer(kind=i32)

The number of digits of the input number.

private pure function count_digits_integer_i64(i) result(num_digits)

Arguments

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

Integer number whose digits are to be counted.

Return Value integer(kind=i64)

The number of digits of the input number.