gps to magnetic compass

I am trying to convert my current gps coordinates and the desired gps coordinates to a compass heading. I am trying to use the equations for the great circle. When I compile I am getting this error. error: invalid operands of types 'double' and 'double' to binary 'operator%' I'm pretty sure it does not like my modulo operator, but because atan2 returns a value between -180 and 180 I need to use it.

double lat_gps, lon_gps, lat, lon;
float desired_heading;

          desired_heading =atan2(cos(lat_gps)*sin(lat)-sin(lat_gps)*cos(lat)*sin(lon-lon_gps),sin(lon-lon_gps)*cos(lat));  
          desired_heading = (desired_heading*(180.0/3.14)+360.0) % 360.0;
          motor_control(desired_heading);

Two points.

First double and float are both the same size floating point variables in the arduino platform (The double implementation on the Arduino is currently exactly the same as the float, with no gain in precision).

.
Second from the arduino reference on the Modulo function ( http://arduino.cc/en/Reference/Modulo )

The modulo operator does not work on floats.

Lefty

As the compiler says, the modulo operator cannot be used on floating point numbers. If you don't need the heading to have decimal places, just cast it to an int and use modulo. If you do, add an additional step and only add the 360 if the interim result is less than 0.