function rat_to_r8_test ( )

%*****************************************************************************80
%
%% rat_to_r8_test() tests rat_to_r8().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 July 2021
%
%  Author:
%
%    John Burkardt
%
  ndig = 4;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'rat_to_r8_test():\n' );
  fprintf ( 1, '  rat_to_r8() converts a rational to a real number.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The maximum number of digits allowed is %d\n', ndig );

  fprintf ( 1, '\n' );
  fprintf ( 1, '     R   =>  A / B  =>  R2\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 10
    r = rand ( 1, 1 );
    r = 10.0 * ( r - 0.25 );
    [ a, b ] = r8_to_rat ( r, ndig );
    r2 = rat_to_r8 ( a, b );
    fprintf ( 1, '  %10g  %6d  %6d  %10g\n', r, a, b, r2 );
  end

  return
end
