get_digit Function

public pure function get_digit(number, position) result(res)

Get the i-th digit of an integer number, counting from the right and starting at 1.

Arguments

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

The integer whose digit is to be extracted.

integer, intent(in) :: position

The position of the digit to extract, counting from the right and starting at 1.

Return Value integer


Called by

proc~~get_digit~~CalledByGraph proc~get_digit get_digit proc~stop_message_c stop_message_c proc~stop_message_c->proc~get_digit

Source Code

   integer pure function get_digit(number, position) result(res)
   !! Get the `i`-th digit of an integer `number`, counting from the right and starting at 1.
      integer, intent(in) :: number
         !! The integer whose digit is to be extracted.
      integer, intent(in) :: position
         !! The position of the digit to extract, counting from the right and starting at 1.

      res = mod(abs(number)/(10**(position - 1)), 10)

   end function get_digit