How do i limit my accelerometer movement

So i have a topdown space shooter type of game and i need to limit its horizontal movement `
public class rocketMove : MonoBehaviour {

public class rocketMove : MonoBehaviour {

    public float rocketSpeed;


    // Use this for initialization
    void Start () {
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

    }

    // Update is called once per frame
    void Update()
    {
        float temp = Input.acceleration.x;

        if (GetComponent<PUCol>().isInverted == false)
        {
            transform.Translate(temp * Time.deltaTime * rocketSpeed, 0, 0);


        }
        if (GetComponent<PUCol>().isInverted == true)
        {
            transform.Translate(-temp * Time.deltaTime * rocketSpeed, 0, 0);
            
        }

this is the code i have for movement, i need to limit the movement in between -2.8f and 2.8f. Please help im lost :confused:

Try Mathf.Clamp

transform.position.x = Mathf.Clamp(transform.position.x, -2.8f, 2.8f)