function digits_sexagesimal_print ( d, p )

%*****************************************************************************80
%
%% digits_sexagesimal_print() prints sexagesimal digits.
%
%  Discussion:
%
%    R = d(1) * 60^p + d(2) * 60^(p-1) + ... + d(n) * 60^(p+1-n) approximately
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    21 June 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer D(N): the digits
%
%    integer P: the power of 60 multiplying the first digit.
%
  n = length ( d );
  p1 = max ( p, 0 );
  p2 = min ( p+1-n, 0 );

  for p3 = p1 : -1 : p2
    if ( p+1-n <= p3 && p3 <= p )
      i = p - p3 + 1;
      if ( p3 == 0 )
        fprintf ( 1, '%02d.', d(i) );
      elseif ( p3 == p2 )
        fprintf ( 1, '%02d', d(i) );
      else
        fprintf ( 1, '%02d,', d(i) );
      end
    else
      if ( p3 == 0 )
        fprintf ( 1, '%02d.', 0 );
      else
        fprintf ( 1, '%02d,', 0 );
      end
    end
  end
  fprintf ( 1, '\n' );

  return
end
