Re: double exclamation mark meaning ?
On Thu, Dec 6, 2012 at 4:50 AM, Shraddha Kamat 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 ? > this is c question, right, google is your friend > -- Shraddha > > > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: double exclamation mark meaning ?
Hi, On Thu, Dec 6, 2012 at 3:20 PM, Shraddha Kamat 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). !(20) > 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). !!(20) > 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@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: double exclamation mark meaning ?
> 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 ? > This is a kind of cast to a "bool". After applying !!(x), the value will be either 0 or 1. It's roughly equivalent to (((x) != 0) ? 1 : 0) Regards. -- Yann Droneaud OPTEYA ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
double exclamation mark meaning ?
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 ? -- Shraddha ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies