r8_wrap <- function ( 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: # # 14 September 2026 # # Author: # # John Burkardt # # Input: # # real r: a value. # # real rlo, rhi: the desired bounds. # # Output: # # real value: a "wrapped" version of the value. # { value = rlo + ( r - rlo ) %% ( rhi - rlo ) return ( value ) }