function r = r8_wrap ( r, rlo, rhi )

%*****************************************************************************80
%
%% R8_WRAP forces an R8 to lie between given limits by wrapping.
%
%  Discussion:
%
%    An R8 is a real value.
%
%  Example:
%
%    RLO = 4.0, RHI = 8.0
%
%     R  Value
%
%    -2     8
%    -1     4
%     0     5
%     1     6
%     2     7
%     3     8
%     4     4
%     5     5
%     6     6
%     7     7
%     8     8
%     9     4
%    10     5
%    11     6
%    12     7
%    13     8
%    14     4
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 June 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real R, a value.
%
%    real RLO, RHI, the desired bounds.
%
%  Output:
%
%    real R, a "wrapped" version of the value.
%
  r = rlo + mod ( r - rlo, rhi - rlo );

  return
end
