Loom_weaver's first post was exactly what you wanted. Alternatively, consider the pseudocode:
1 2 3
| min = ..., max = ..., range = max - min; while(value < min) value += range; while(value > max) value -= range; |
Which might prevent rounding errors for floating point numbers or overflow issues with integral numbers. This is not the fastest method, but it's the basic idea behind the modulus operator (remainder division.) You will need to "reset" the value within an acceptable range to prevent those types of bugs with large integers/floating points. You will have to split up the object, shift, and draw up to four separate "quadrants" (red, orange, yellow, and gray) to display the scene correctly. If you can't split every object then you may have to draw it four times for each screen boundary (drawing most of the object off screen.)