I would use a signed variable to represent the distance between the desired target position, and the actual target position. So for example a positive value could mean that the device is too far to the right, and negative that it is too far to the left.
From this signed value you will need to decide what action the motors need to take. Again I would represent this by a signed value with 0 meaning do nothing (no power to either motor), a positive value meaning apply power in one direction, a negative value meaning apply power in the other direction.
To actually implement that action you would test the sign of the value to decide which direction to move each motor, and the magnitude to decide how much power to apply.
The missing link is how you get from the (signed) positional error to the (signed) required action. The simplest approach would be to just make the action be proportional to the error. If that results in a system which is too slow to respond or subject to overshoots or is subject to oscillations then you might need something more sophisticated such as a PID control algorithm. Try the simple stuff first though.