Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
In a Vincenty Direct Formula, there is an expression

C++
lon2 = (lon1.toRad()+L+3*Math.PI) % (2*Math.PI) - Math.PI; 

/* Where lon2, lon1 is in degrees,L in double, Math.PI(Predefined value for PI) is a constant double */


But there is an error that says: "Expression must have integral or enum type" and also shows that the left hand side of % has a double and right hand side has a constant double. But that is the formula. How do I get rid of this?
Posted
Updated 24-Apr-12 23:05pm
v2

The modulo operator % can't be used with floating point operands. Use the fmod() function to calculate the remainder for floating point values.
 
Share this answer
 
Comments
Sumal.V 25-Apr-12 5:34am    
Thank u very much :)
So? A Double % a Double gives a Double, doesn't it? So if it expects an integer for lon2 it will complain unless you cast it to an integer explicitly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900