Mathf.Clamp Negative min not negative?

Started a new project last week and decided to take a new approach to character movement and rotation and to bind the look up and down angles im trying to use Mathf.Clamp which i’ve used before but for some reason it doesn’t like that negative min as it won’t allow the rotation to go to -40 only to zero and then snaps the rotation to positive 40 which is very strange. Also note the camera is a child of a game object, and i’m trying to modify its y axis locally which is why I use local rotation.

Here is the code, I’m sure its something very simple and i’m just being blind but I have tried everything I can think of.

public class Rotation : MonoBehaviour 
{
	[Range(0, 10)]
	public float rotationSpeed;

	public Camera cam;

	void Update () 
	{
		float rotateX = Input.GetAxis ("Mouse X");
		float rotateY = -Input.GetAxis ("Mouse Y"); 

		transform.Rotate (0, rotateX, 0);

		rotateY *= rotationSpeed;

		cam.transform.Rotate (rotateY, 0, 0);

		Vector3 rot = cam.transform.localRotation.eulerAngles;
		rot.x = Mathf.Clamp (rot.x, -40, 40); //<--- Negative 40 not working :(

		//Debug.Log (rot);

		cam.transform.localRotation = Quaternion.Euler (rot);
	}
}

Assuming the problem is at the rotation component, did you try this?

var xRotation = Mathf.Clamp (rot.x, -40, 40);
if (xRotation < 0) xRotation = 360 + xRotation; // e.g. 360 + -40 = 320 which is the same rotation
rot.x = xRotation;