IF statement - Error: expression must have integral or unscoped enum type

What am I doing wrong here?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int main()
{
	for (double a = 600851475143 / 2; a > 0; a--)
	{
		if (a % 2 == 0)  //a is underlined red with the error
		{
			continue;
		}
	}
	return 0;
}
You can't use the % operator on floating point types such as float or double.
Okay thank you. Is there no way to use % with a number too large for long int?
The % operator works with all integer types so it will work with long int just fine. If long int is not big enough you could try long long int instead.
Very cool, I didn't know long long was a thing! I am really new to this... thanks again.
Topic archived. No new replies allowed.