473,952 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what's the two !! usage?

hi all,

in the linux kernel code compiler.h
i read
#define likely(x) __builtin_expec t(!!(x), 1)

#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
#define __builtin_expec t(exp,c) (exp)
#endif

what's the meaing of !!(x)?

thanks

baumann@pan

Nov 14 '05 #1
3 1335
ba*********@gma il.com writes:
what's the meaing of !!(x)?


It transforms any nonzero value to 1 and leaves zero unchanged.
It transforms null pointers to 0 and any nonnull pointer to 1.
It is equivalent to (x != 0).
--
Ben Pfaff
email: bl*@cs.stanford .edu
web: http://benpfaff.org
Nov 14 '05 #2
ba*********@gma il.com wrote:
hi all,

in the linux kernel code compiler.h
i read
#define likely(x) __builtin_expec t(!!(x), 1)

#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
#define __builtin_expec t(exp,c) (exp)
#endif

what's the meaing of !!(x)?

thanks

baumann@pan


!! is "not not"

That is, x is an integer. if x is 0 then !x is 1. If x is not 0 then !x
is 0.

so say x is 42. !x is 0 and !!x is 1.

--
Peter MacMillan
e-mail/msn: pe***@writeopen .com
icq: 1-874-927

GCS/IT/L d-(-)>-pu s():(-) a- C+++(++++)>$ UL>$ P++ L+ E-(-) W++(+++)>$
N o w++>$ O !M- V PS PE Y+ t++ 5 X R* tv- b++(+) DI D+(++)>$ G e++ h r--
y(--)
Nov 14 '05 #3
Peter MacMillan <pe***@writeope n.com> wrote:
ba*********@gma il.com wrote:
#define likely(x) __builtin_expec t(!!(x), 1) what's the meaing of !!(x)?


!! is "not not"

That is, x is an integer.


A scalar, rather. It works for pointers and floating point numbers as
well as for integers.

Richard
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2229
by: Jonathan Fine | last post by:
Giudo has suggested adding optional static typing to Python. (I hope suggested is the correct word.) http://www.artima.com/weblogs/viewpost.jsp?thread=85551 An example of the syntax he proposes is: > def f(this:that=other): > print this This means that f() has a 'this' parameter, of type 'that'. And 'other' is the default value.
5
2928
by: John Smith | last post by:
I am writing a program which should keep running if not interrupted. While testing the program, I noticed that when the program was first run, the cpu usage (on WinXP) was between 0 to 2 %. In the next morning, the cpu usage had jumped to 100%. I observed the same behavior on two different machines. Since the program does repetitive jobs, there is no reason the cpu load should change. What would cause this kind of behavior? I have no...
8
2224
by: GeekBoy | last post by:
I understand the benefit of pushing the StateServer process onto another computer to "balance" the load and take some cpu and memory usage off the web server, but how much could it possibly help? Especially when you're talking about marshalling the data back and forth across your network (although on the same segment)? Here's my scenario: Each login stores exactly 3 session variables; one integer and two strings. That's it. Never, ever,...
15
11013
by: dee | last post by:
Hi, What is the maximum number of minutes for Session timeout that I can specify in web.config? Thanks. Dee
669
26638
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
7
7589
by: Leonel Gayard | last post by:
Hi all, I had to write a small script, and I did it in python instead of shell-script. My script takes some arguments from the command line, like this. import sys args = sys.argv if args == : print """Concat: concatenates the arguments with a colon (:) between them
10
2124
by: rdemyan via AccessMonster.com | last post by:
My app contains utility meter usage. One of the things we have to deal with is when a usage is clearly incorrect. Perhaps someone wrote the meter reading down incorrectly or made a factor of 10 error when entering the reading, etc. At other times the usage is zero or somehow was entered as a negative number. So I'm thinking about adding functionality to search for such anomalies. For instance, show months where the meter reading is...
3
9410
by: Sirisha | last post by:
I am using the following code to get the CPU usage PerformanceCounter myCounter; myCounter = new PerformanceCounter(); myCounter.CategoryName = "Processor"; myCounter.CounterName = "% Processor Time"; myCounter.InstanceName = "_Total"; for(int i=0; i < 20; i++)
2
2345
by: Sin Jeong-hun | last post by:
In short, is there any way to know the very code that is currently hogging the CPU? I've written an application which continously GETting web pages using HttpWebRequest's asynchronous methods (it only GETs responses (BegingGetResponse,EndGetResponse), not reads the stream contents). I've read articles about asynchronous request operations. I aborted timed out requests based on the article. ( http://www.developerfusion.co.uk/show/4654/ )...
93
3726
by: lorlarz | last post by:
Here, let's see what you JavaScript programmers have got Here is a place to share your large or larger full-blown JavaScript applications: real.comp.lang.js.apps (a new google group) Here is the description of this open public newsgroup: A place where good full-length, full-featured, pure (or near-pure) JavaScript large and larger applications are described and their code shared and explained. The language used for browser programs...
0
11616
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11216
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11385
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9921
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7454
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6242
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3568
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.