lkml.org 
[lkml]   [2005]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: A pettiness question.
Ustyugov Roman wrote:
>>Hi, All.
>>
>> I found there are use double operator ! continuously sometimes in
>>kernel.
>>e.g:
>>
>> static inline int is_page_cache_freeable(struct page *page)
>> {
>> return page_count(page) - !!PagePrivate(page) == 2;
>> }
>>
>> Who would like tell me why write like above?
>>
>>
>> Thanks in advanced.
>>
>>
>>Liyu
>
>
> For example,
>
> int test = 5;
> !test will be 0, !!test will be 1.
>
> This give a enum of {0,1}. If test is not 0, !!test will give 1, otherwise 0.
>
> Am I right?

Yes, !! converts {zero,not-zero} to {0,1} which is useable
in arithmetic.

--
Eyal Lebedinsky (eyal@eyal.emu.id.au) <http://samba.org/eyal/>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-09-21 10:59    [W:0.050 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site