function ziggurat_test02 ( )

%*****************************************************************************80
%
%% ziggurat_test02() tests r4_uni().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 October 2013
%
%  Author:
%
%    John Burkardt
%
  u32_max_half = uint32 ( 2147483648 );
  u32_max      = uint32 ( 4294967296 );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'ziggurat_test02():\n' );
  fprintf ( 1, '  r4_uni() returns pseudorandom uniformly distributed\n' );
  fprintf ( 1, '  real numbers between 0 and 1.\n' );

  for j = 0 : 2

    if ( mod ( j, 2 ) == 0 )
      key = uint32 ( 123456789 );
    else
      key = uint32 ( 987654321 );
    end

    fprintf ( 1, '\n' );
    fprintf ( 1, '  %6d  %12u\n', 0, key );
    fprintf ( 1, '\n' );

    for i = 1 : 10
      [ value, key ] = r4_uni ( key );
      if ( key < u32_max_half )
        skey = key;
      else
        skey = - int32 ( u32_max - key ) + 1;
      end
      fprintf ( 1, '  %6d  %12d  %12u  %f\n', i, skey, key, value );
    end

  end

  return
end
