Seeing imprecise rotation value rotating around a root

I have an empty which is parented to a camera.

I’ve used variations of the following code to tell the camera to rotate 90 degrees around the empty on a keypress:

if (Input.GetKeyDown (KeyCode.RightArrow))
    			transform.Rotate (transform.rotation.x,transform.rotation.y+rotationIncrement,transform.rotation.z * rotationSpeed * Time.deltaTime);

I’ve set the rotationIncrement variable to integer and float values of 90 and 90.0f, yet still see results like 89.2, 91.3, etc. adding up on each rotation.

I’ve also done it with rotationSpeed and deltaTime left out but it doesn’t change the result.

Is there a way to avoid the imprecision? Or do I just need to do a < or > check and clamp the result of each rotation?

The problem is that transform.rotation is not a representation of angles. It is a Quaternion, a non-intuitive construct with vales in the range of -1.0 to 1.0. If you want to get the angles, you can use transform.eulerAngles. But reading from eulerAngles has pitfalls. There are multiple eulerAngle representations for any given physical one, and Unity changes that representation. Try eulerAngles and see if it works for you. If it does not, create your own Vector3 to store the angles. Make all manipulations with that Vector3 and then assign the result to transform.eulerAngles. And if you decide to work with eulerAngles, read the warnings on the reference page.