Help making math more accurate

Hey, I'm making a 2 DOF arm, and am having some trouble getting precise angle calculations out of my arduino. Is there something I can do to make them more accurate? I'm new to arduino so I recognize my programming skills aren't that great, so I may be doing something quite obvious wrong.

      float c = sqrt(sq(x) + sq(y)); //pythagorean theorem to find imaginary line c
      float middleRad = acos((sq(c)-sq(a)-sq(b))/((-2)*a*b)); //law of cosines, returns angle of middle servo in radians

 //law of cosines for base angle
      float baseRad = acos((sq(b)-sq(a)-sq(c))/((-2)*a*c)) + atan(y/x);

 //converting Radians to Degrees:
      float baseDeg = baseRad*(180/PI);
      float middleDeg = middleRad*(180/PI);

Is there something I can do to make them more accurate?

Using an 8 bit microcontroller? No.

But, why are you converting from radians to degrees?

tinkerkid: returns angle of middle servo in radians

What type of servos?

The precision of your calculations will most likely be much higher than the precision of your servos.

Servos need integer values - either numbers of degrees or numbers of microseconds.

Why not do all your maths using integers (including long ones if appropriate). That way it is easy to keep control of the precision.

...R

probably should have explained more. I'm converting to degrees so that the angles are now in the range of 0-180 for the servos to read. is there a better way to have the servos write to the angles?

is there a better way to have the servos write to the angles?

Servo.writeMicroseconds