I am trying to figure out the meaning of the following codes.
In here if (!msize)
checking to see if msize
is zero or if msize
is 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
if (msize == 0)
msize = 1 / msize; /* provoke a signal */
It's checking if msize
is 0, and is equivalent to writing if (msize == 0)
. If it is, it deliberately performs a divide by zero.
if(!msize) is simply opposite of if(msize) here if(!msize) this expression becomes true if msize==0 or NULL...
It means "If msize is EQUAL to 0". Remember that NOT in this instance is a logical operator. Also NULL is a standard MACRO in C.
However if msize is a boolean, then "if (!msize)
" is equivalent to "if (msize == false)
".
On a side note:-
5.6 Multiplicative operators
4) The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined; otherwise (a/b)*b + a%b is equal to a. If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined79). (emphasis mine)
Also you may get the result as 1.#IND000 which is basically the representation of NaN, basically IND is the representation of NaN ( Not a Number ) in Windows system. IND stands for "indeterminate form", mostly result from illegal operation like divided by zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With