简体   繁体   中英

Validation of long long Int in C behaving unusually

I am writing an MPI program in which rank 0 reads parameters from a file and broadcasts the parameters on all the other ranks using MPI_BCAST.

I am trying to validate if the long long integers obtained are non zero or not in C, While I can validate if the variables are non zero, but for I cannot validate the converse. (I have initialized the variables to zero). I have verified that the broadcast does work correctly but yet I am unable to validate

if ((min_length==0LL) || (max_length==0LL) || (stride_length==0LL) || (nflops == 0LL))

Whereas I can validate its converse ie

if ((min_length!=0LL) || (max_length!=0LL) || (stride_length!=0LL) || (nflops != 0LL))

Just to clear out the stuff, none of the values are zero, if any value obtained is zero, my program needs to terminate.

Thank you in advance.

Use de Morgan is you want to inverse/negate your condition

if (min_length!=0LL && max_length!=0LL && stride_length!=0LL && nflops != 0LL) {
}

http://en.wikipedia.org/wiki/De_Morgan%27s_laws

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM