How do I rotate using a negative angle value?,How to get the negative angle of an object?

I’m making a game where the player can rotate a platform. However, I don’t want the player to be able to rotate the platform completely around. To prevent this I attempted to add if statements that would check the current value of the platforms angle, and if the angle was more or less than a specific angle it would continue to rotate when a specific key is being pressed. I understand that a negative angle isn’t technically a thing but Unity’s transform inspector shows a negative angle rather than passing 180 degrees. Is there a way to call that number rather than a number from 360? If not then might someone have an alternate suggestion on how to proceed with my goal?

Here’s an example of the code I’m using.

void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            if (gameObject.transform.rotation.eulerAngles.x < 20)
            {
                transform.Rotate(0.5f, 0, 0);
            }
        }
        if (Input.GetKey(KeyCode.S))
        {
            if (gameObject.transform.rotation.eulerAngles.x > -20)
            {
                transform.Rotate(-0.5f, 0, 0);
            }
        }
    }

You could possibly add in a

float rotation = gameObject.transform.eulerAngles.x;
if(rotation < 0){
    rotation += 360;
}

Then use the rotation variable to test your angles rather than the gameobject angle

Here’s a helper function I use to find the signed equivalent of Euler angles;

public static Vector3 GetSignedEulerAngles (Vector3 angles)
{
	Vector3 signedAngles = Vector3.zero;
	for (int i = 0; i < 3; i++)
	{
		signedAngles _= (angles *+ 180f) % 360f - 180f;*_

* }*
* return signedAngles;*
}
Just pass in your transform’s angles and store the result.