Isn't this like basically mod?

    result = mod(number, max - min) + min;