Is it possible to turn the robot to a certain degree with Compass?

hey guys,

It seems that I solved the problem, just wanted to post my code for some people facing same problem,

I don't know whether this approach is right or not, but it works. I hope it does not affect other parts of my application.
you are more than welcome to comment and suggest a better approach.

void turnRightTheRobot(int angle){
  int currentBearing = getBearing();
  int desiredBearing = currentBearing + angle;
  if(desiredBearing > 359) {
    desiredBearing -= 359;
  }
  do{
    int newBearing = getBearing();
    double desiredBearingSINE = sin(desiredBearing * (PI/180));
    double currentBearingSINE = sin(newBearing * (PI/180));
    
    if(desiredBearingSINE > 0 && currentBearingSINE < 0) {
     newBearing = newBearing - 360;
       }
     if(newBearing >= desiredBearing) {
      moveForward(0, 0);
      break;
    }
    else {
      turnRight(80,80);
    }
   }while(1);
}