bd_to_digits Subroutine

private pure subroutine bd_to_digits(limb, n_limb, exact, n_exact)

Write the big integer out as a decimal digit string, no leading zeros.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: limb(:)
integer(kind=default_int), intent(in) :: n_limb
character(len=*), intent(out) :: exact
integer(kind=default_int), intent(out) :: n_exact

Calls

proc~~bd_to_digits~~CallsGraph proc~bd_to_digits bd_to_digits proc~limb_to_digits limb_to_digits proc~bd_to_digits->proc~limb_to_digits

Called by

proc~~bd_to_digits~~CalledByGraph proc~bd_to_digits bd_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
character(len=LIMB_DIGITS), private :: chunk
integer(kind=default_int), private :: first
integer(kind=default_int), private :: i
integer(kind=default_int), private :: pos

Source Code

   pure subroutine bd_to_digits(limb, n_limb, exact, n_exact)
      !! Write the big integer out as a decimal digit string, no leading zeros.
      integer(int64), intent(in) :: limb(:)
      integer(default_int), intent(in) :: n_limb
      character(len=*), intent(out) :: exact
      integer(default_int), intent(out) :: n_exact
      character(len=LIMB_DIGITS) :: chunk
      integer(default_int) :: i, first, pos

      exact = ""
      call limb_to_digits(limb(n_limb), chunk)
      first = 1_default_int
      do while (first < LIMB_DIGITS .and. chunk(first:first) == "0")
         first = first + 1_default_int
      end do
      pos = LIMB_DIGITS - first + 1_default_int
      exact(1:pos) = chunk(first:LIMB_DIGITS)

      do i = n_limb - 1_default_int, 1_default_int, -1_default_int
         call limb_to_digits(limb(i), chunk)
         exact(pos + 1_default_int:pos + LIMB_DIGITS) = chunk
         pos = pos + LIMB_DIGITS
      end do

      n_exact = pos

   end subroutine bd_to_digits