What does it mean if (! Msize) means?

I am trying to figure out the meaning of the following codes.

Here's if (!msize) checking if msize zero or msize NULL ?

 if (!msize) msize = 1 / msize; /* provoke a signal */ //Example 1: A division-by-zero misuse, in lib/mpi/mpi-pow.c of the Linux kernel, where the entire code will be optimized away. //Compilers, GCC 4.7 and Clang 3.1 
+7
c
source share
3 answers
 if (msize == 0) msize = 1 / msize; /* provoke a signal */ 

Checks if msize is 0, and is equivalent to writing if (msize == 0) . If so, he deliberately performs the division by zero.

+5
source share

This means: "If msize is EQUAL equal to 0". Remember that NOT in this case is a logical operator. NULL is also the standard MACRO in C.

However, if msize is Boolean, then " if (!msize) " is equivalent to " if (msize == false) ".

On a side note: -

5.6 Multiplicative operators

4) The binary / operator gives the quotient, and the binary% operator gives the remainder of dividing the first expression by the second. If the second operand / or% is zero, the behavior is undefined ; otherwise (a / b) * b + a% b is equal to a. If both operands are non-negative, then the remainder is non-negative; if not, the remainder sign is determined by the implementation79). (italics mine)


You can also get the result as 1. # IND000 , which is basically a representation of NaN , basically IND is a representation of NaN (Not a Number) on a Windows system. IND means "indefinite form", mainly due to an illegal operation, for example, divided by zero.

+2
source share

if (! msize) is just the opposite if (msize) Here is if (! msize) this expression becomes true if msize == 0 or NULL ...

+2
source share

All Articles