double exclamation mark meaning ?

Prabhakar Lad prabhakar.csengg at gmail.com
Thu Dec 6 05:07:07 EST 2012


Hi,

On Thu, Dec 6, 2012 at 3:20 PM, Shraddha Kamat <sh2008ka at gmail.com> wrote:
> Hi,
>
> # define likely(x)  __builtin_expect(!!(x), 1)
> # define unlikely(x)    __builtin_expect(!!(x), 0)
>
> I see these !! in the above expressions. Please explain me the
> meaning of those double exclamations. What is their significance ?
>
The Operator ! is used to perform the Boolean operation NOT.
For example:
!(1) ---> Outputs to 0 (false).
!(2.56565) ---> Outputs to 0 (false).
!(2000000000) --------> Outputs to 0 (false).
!(-123)---> Outputs to 0 (false).
!(0)---------> Outputs to 1 (true).
Similarly '!!'  Performs twice NOT operation
!!(1) --->  Outputs to 1 (true).
!!(2.56565) --->  Outputs to 1 (true).
!!(2000000000) -------->  Outputs to 1 (true).
!!(-123)---> Outputs to 1 (true).
!!(0)--------->  Outputs to 0 (false).

Hope that clears your doubt.

Regards,
--Prabhakar Lad

> -- Shraddha
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



More information about the Kernelnewbies mailing list