limb_to_digits Subroutine

private pure subroutine limb_to_digits(value, chunk)

Expand one limb into exactly LIMB_DIGITS zero padded characters, table driven the same way pic_strings converts integers.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: value
character(len=*), intent(out) :: chunk

Called by

proc~~limb_to_digits~~CalledByGraph proc~limb_to_digits limb_to_digits proc~bd_to_digits bd_to_digits proc~bd_to_digits->proc~limb_to_digits proc~expand_exact expand_exact proc~expand_exact->proc~bd_to_digits proc~to_string_fixed_dp to_string_fixed_dp proc~to_string_fixed_dp->proc~expand_exact proc~to_string_sci_dp to_string_sci_dp proc~to_string_sci_dp->proc~expand_exact interface~to_string_fixed to_string_fixed interface~to_string_fixed->proc~to_string_fixed_dp proc~to_string_fixed_sp to_string_fixed_sp interface~to_string_fixed->proc~to_string_fixed_sp interface~to_string_sci to_string_sci interface~to_string_sci->proc~to_string_sci_dp proc~to_string_sci_sp to_string_sci_sp interface~to_string_sci->proc~to_string_sci_sp proc~to_string_fixed_sp->proc~to_string_fixed_dp proc~to_string_sci_sp->proc~to_string_sci_dp

Variables

Type Visibility Attributes Name Initial
integer(kind=default_int), private :: digit
integer(kind=default_int), private :: i
integer(kind=int64), private :: remaining

Source Code

   pure subroutine limb_to_digits(value, chunk)
      !! Expand one limb into exactly `LIMB_DIGITS` zero padded characters,
      !! table driven the same way `pic_strings` converts integers.
      integer(int64), intent(in) :: value
      character(len=*), intent(out) :: chunk
      integer(default_int) :: i, digit
      integer(int64) :: remaining

      remaining = value
      do i = LIMB_DIGITS, 1_default_int, -1_default_int
         digit = int(mod(remaining, 10_int64), default_int) + 1_default_int
         chunk(i:i) = ALL_DIGITS(digit:digit)
         remaining = remaining/10_int64
      end do

   end subroutine limb_to_digits