Ah... let me see if I understand this.
Quote:

I'm trying to make an entity rotate while standing on a wall so when the normal.z equals 0


Your wall is vertical then...
Quote:

and tilt equals 90 or -90 degrees


...and your entity (a gun turret maybe?) is stuck to the side of the wall, facing either straight up or straight down. Is that right?
Quote:

if seems that the rotation afterwards isn't quite accurate anymore


You probably won't get pinpoint accuracy with 3 decimal places of precision, which is the best a var can manage.

With the bigger picture, though, I still don't understand what you are trying to do. I work better with a visual goal in mind, thinking about a gun turret or a spy camera or whatever. Unless that's proprietary information...