function r8_next_previous_test ( )

%*****************************************************************************80
%
%% r8_next_previous_test() tests r8_next() and r8_previous().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 January 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8_NEXT_PREVIOUS_TEST():\n' );
  fprintf ( 1, '  R8_NEXT computes the "next" real number.\n' );
  fprintf ( 1, '  R8_PREVIOUS computes the "previous" real number.\n' );

  mu = 1.0;
  sigma = 1.0;

  for i = 1 : 10

    x1 = mu + sigma * randn ( );
    x2 = r8_next ( x1 );
    x3 = r8_previous ( x2 );
    x4 = r8_previous ( x1 );
    x5 = r8_next ( x4 );

    fprintf ( 1, '\n' );
    fprintf ( 1, '  X = %24.20g  X+ = %24.20g  X+- = %24.20g\n', x1, x2, x3 );
    fprintf ( 1, '  X = %24.20g  X- = %24.20g  X-+ = %24.20g\n', x1, x4, x5 );

    mu = - 10.0 * mu;
    sigma = 2.0 * sigma; 

  end

  return
end
