This is what I’ve done for checking the divisibility of a number by 2*M_PI. “w” is a constant that’s 2/3 and t is the variable that varies by t += dt, where dt is 0.1. I’m trying to use the mod operator, %, to see if something is divisible. But its not working.
bool divisible;
real w = 2/3;
real t;
if((w*t) % 2*M_PI == 0)
{
divisible = true;
}
else
{
divisible = false;
}
This is the error that I get, “invalid operands of types ‘real’ and ‘int’ to binary ‘operator%’”
What does this mean? How do I get this to work? So do I need to make w and t an int? They can’t be because w is 2/3, and t increments from 0 by 0.1. Can someone please help me?
Use
std::fmodinstead, it operates on doubles rather than the integral%operator.