def modrange(x, low, high):
	"""mod x such that it is between [low, high).

		>>> modrange(2.5, 1, 2)
		1.5
		>>> modrange(3., 1, 2)
		1.0
	"""
	spread = high - low
	diff = x - low
	mod = diff % spread
	return low + mod