I am attempting to convert a negative angle (in degrees) to positive. But I am getting a compile error saying:
test.cpp invalid operands of types 'double' and 'int' to binary 'operator%'
test.cpp invalid operands of types 'float' and 'int' to binary 'operator%'
My code:
double to_positive_angle(double angle)
{
return ((3600000 + angle) % 360);
}
float to_positive_angle(float angle)
{
return ((3600000 + angle) % 360);
}
Its obviously because I am trying to use the Modulus operator on a Float and Double.
Are the any ways I can successfully convert a negative angle (float) to a positive one (float)? Or ways that I can overcome the modulus compile error?
3600000to the angle? - Alanxsuch thatcos(x)==0orsin(x)==1, etc. This also means successive rounds around the circle will not give you identical values forsinandcos. With degrees, all of those problems go away. Moreover, degrees are better than the other natural option,sinpi(x)defined assin(pi*x), because even in that form it's impossible to represent 30 and 60 degree angles exactly (and thus there's noxwithsin(x)==0.5, etc.). - R.. GitHub STOP HELPING ICE