Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing long long with 0

long long llIdx = foo();
if (llIdx > 0LL) // Can I use 0 here?
  ...

Is there any problem if I use 0 instead of 0LL in above code?

When should I prefer 0LL over 0?

like image 755
Deqing Avatar asked Feb 17 '15 00:02

Deqing


1 Answers

Yes, you can use a plain 0 here. The compiler would look at the type of each argument to > and promote the smaller one so that they are the same size.

Thus llIdx > 0 and llIdx > 0LL are equivalent.

like image 120
kdopen Avatar answered Oct 21 '22 18:10

kdopen