linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: A pettiness question.
@ 2005-09-21 19:46 Nick Warne
  2005-09-21 20:05 ` Vadim Lobanov
  2005-09-22  2:43 ` Fawad Lateef
  0 siblings, 2 replies; 15+ messages in thread
From: Nick Warne @ 2005-09-21 19:46 UTC (permalink / raw)
  To: linux-kernel

>> This give a enum of {0,1}. If test is not 0, !!test will give 1,
>> otherwise 0.
>>
>> Am I right?
> 
> Yes.  I think of it as a "truth value" predicate (or operator).

Interesting.  I thought maybe this way was trick, until later I experimented.

My post here (as Bill Stokes):

http://www.quakesrc.org/forums/viewtopic.php?t=5626

So what is the reason to doing !!num as opposed to num ? 1:0 (which is more 
readable I think, especially to a lesser experienced C coder).  Quicker to 
type?

My quick test shows compiler renders both the same?

Nick
-- 
"When you're chewing on life's gristle,
Don't grumble, Give a whistle..."

^ permalink raw reply	[flat|nested] 15+ messages in thread
* A pettiness question.
@ 2005-09-21  7:49 liyu
  2005-09-21  8:00 ` Ustyugov Roman
  2005-09-21 19:11 ` Bill Davidsen
  0 siblings, 2 replies; 15+ messages in thread
From: liyu @ 2005-09-21  7:49 UTC (permalink / raw)
  To: LKML

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2005-09-25 14:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4PiLw-2yn-25@gated-at.bofh.it>
     [not found] ` <4Pj4M-3as-1@gated-at.bofh.it>
     [not found]   ` <4PtnM-1oW-55@gated-at.bofh.it>
     [not found]     ` <4Pynh-fp-1@gated-at.bofh.it>
2005-09-25 14:38       ` A pettiness question Bodo Eggert
2005-09-21 19:46 Nick Warne
2005-09-21 20:05 ` Vadim Lobanov
2005-09-22  7:10   ` Helge Hafting
2005-09-22 12:21     ` Steven Rostedt
2005-09-22 14:40       ` linux-os (Dick Johnson)
2005-09-22  2:43 ` Fawad Lateef
  -- strict thread matches above, loose matches on Subject: below --
2005-09-21  7:49 liyu
2005-09-21  8:00 ` Ustyugov Roman
2005-09-21  8:57   ` Eyal Lebedinsky
2005-09-21  9:01   ` Fawad Lateef
2005-09-21  9:30     ` Andrea Arcangeli
2005-09-23  2:36       ` Vadim Lobanov
2005-09-21 15:08   ` Randy.Dunlap
2005-09-21 19:11 ` Bill Davidsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).