function r8_to_rat_test ( )

%*****************************************************************************80
%
%% R8_TO_RAT_TEST tests R8_TO_RAT.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    13 April 2009
%
%  Author:
%
%    John Burkardt
%
  ndig = 4;

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

  seed = 123456789;

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

  for i = 1 : 10
    [ r, seed ] = r8_uniform_01 ( seed );
    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
