what does it do?
#define BLACKBOX(x) ((x)&((x)-1)) 8 1807
puzzlecracker wrote: what does it do? #define BLACKBOX(x) ((x)&((x)-1))
For unsigned integers x and signed integers x in 2s complement
with x>(integer type's minimum value), this clears the least
significant set bit.
It also works for 1s complement signed integers and
x!=0 && x!=1 && x>(integer type's minimum value)
-Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
puzzlecracker wrote: what does it do? #define BLACKBOX(x) ((x)&((x)-1))
Clears the least significant set bit in x. This works on all unsigned
numbers and all signed numbers (except "sign-magnitude" negative even
numbers).
Luke Wu wrote: puzzlecracker wrote:
what does it do? #define BLACKBOX(x) ((x)&((x)-1))
Clears the least significant set bit in x. This works on all unsigned numbers and all signed numbers (except "sign-magnitude" negative even numbers).
.... and except for x==T_MIN where T is the respective integer type;
in the case of 1s complement you cannot rely on 0 not switching
its representation, so x==0 and x==1 are not guaranteed to work
either.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
> puzzlecracker wrote: what does it do? #define BLACKBOX(x) ((x)&((x)-1))
What do you think it does?
If you want to 'test' clc, at least try to be original.
Michael Mair wrote: For unsigned integers x and signed integers x in 2s complement with x>(integer type's minimum value), this clears the least significant set bit. It also works for 1s complement signed integers and x!=0 && x!=1 && x>(integer type's minimum value)
No, consider the following (high bit is sign-bit):
1c or 2c(C99) sm
x : 10000000 10000000 10000000 01111111
x - 1: 10000000 01111111 10000000 10000000
& : 10000000 00000000 10000000 00000000
The result could be a trap representation.
Note also that C89 potentially allows negative representations
beyond 2c, 1c and sm.
--
Peter
On 21 Feb 2005 13:08:16 -0800, "Luke Wu" <Lo***********@ gmail.com> wrote: puzzlecracke r wrote: what does it do? #define BLACKBOX(x) ((x)&((x)-1))
Clears the least significant set bit in x. This works on all unsigned numbers and all signed numbers (except "sign-magnitude" negative even numbers).
Inputting the integer '8' causes the "function" to return zero. Not
suprizing, since the original poster is a known troll. bk***@ncf.ca (Raymond Martineau) writes: On 21 Feb 2005 13:08:16 -0800, "Luke Wu" <Lo***********@ gmail.com> wrote:puzzlecrack er wrote: what does it do? #define BLACKBOX(x) ((x)&((x)-1))
Clears the least significant set bit in x. This works on all unsigned numbers and all signed numbers (except "sign-magnitude" negative even numbers).
Inputting the integer '8' causes the "function" to return zero. Not suprizing, since the original poster is a known troll.
8 has only one bit set. Clearing that bit, which is necessarily
the least significant set bit, yields 0. Thus, this is correct
behavior.
--
int main(void){char p[]="ABCDEFGHIJKLM NOPQRSTUVWXYZab cdefghijklmnopq rstuvwxyz.\
\n",*q="kl BIcNBFr.NKEzjwC IxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+= strchr(p,*q++)-p;if(i>=(int)si zeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Raymond Martineau wrote: On 21 Feb 2005 13:08:16 -0800, "Luke Wu" <Lo***********@ gmail.com>
wrote: puzzlecracke r wrote: what does it do? #define BLACKBOX(x) ((x)&((x)-1)) Clears the least significant set bit in x. This works on all
unsignednumbers and all signed numbers (except "sign-magnitude" negative
evennumbers).
Inputting the integer '8' causes the "function" to return zero.
Yes, exactly as Luke said. What's your point?
Not suprizing, since the original poster is a known troll.
What are you on about?
Peter Nilsson wrote: puzzlecrack er wrote:
what does it do? #define BLACKBOX(x) ((x)&((x)-1))
What do you think it does?
If you want to 'test' clc, at least try to be original.
Ack.
Michael Mair wrote:
For unsigned integers x and signed integers x in 2s complement with x>(integer type's minimum value), this clears the least significant set bit. It also works for 1s complement signed integers and x!=0 && x!=1 && x>(integer type's minimum value) No, consider the following (high bit is sign-bit):
1c or 2c(C99) sm x : 10000000 10000000 10000000 01111111 x - 1: 10000000 01111111 10000000 10000000 & : 10000000 00000000 10000000 00000000
The result could be a trap representation.
Just to make sure: Your "no" is referring to the fact that we
could get a trap representation? Or do you mean that the
formulation "least significant bit" is incorrect?
I am not sure what you want to say with the sign-magnitude example
-- most certainly the "lowest" bit of x is not cleared.
Note also that C89 potentially allows negative representations beyond 2c, 1c and sm.
Thank you for the reminder (mostly, I assume C99 _restrictions_
for everything and am surprised if C89 is not as strict).
Cheers
Michael
--
E-Mail: Mine is a gmx dot de address. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro capabilities, unfortunately. I'd like to know if it may
be possible to add a powerful macro system to Python, while
keeping its amazing syntax, and if it could be possible to
add Pythonistic syntax to Lisp or Scheme, while keeping all
of the...
|
by: Chris Cioffi |
last post by:
I started writing this list because I wanted to have definite points
to base a comparison on and as the starting point of writing something
myself. After looking around, I think it would be a waste of time to
start writing yet another IDE and so am now thinking in terms of new
features/plug-ins for existing systems.
Right now I mostly use Komodo Personal and it's pretty close to being
what I want. They don't currently support plug-ins,...
|
by: perseus |
last post by:
I think that everyone who told me that my question is irrelevant,
in particular Mr. David White,
is being absolutely ridiculous. Obviously, most of you up here
behave like the owners of the C++ language. A C++ interface
installation IS ABOUT THE C++ LANGUAGE! The language
does not possess the ability to handle even simple file directory
manipulation.
Those wise people that created it did not take care of it. So, BOOST
is a portable...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from software giant such as Microsoft SQL
Server, Oracle, and Sybase?
Is PostgreSQL reliable enough to be used for high-end commercial
application? Thanks
|
by: Jukka K. Korpela |
last post by:
I have noticed that the meaning of visibility: collapse has been discussed
on different forums, but with no consensus on what it really means.
Besides, implementations differ.
The specification says:
"The 'visibility' property takes the value 'collapse' for row, row group,
column, and column group elements. This value causes the entire row or
column to be removed from the display, and the space normally taken up by
the row or column to...
| |
by: Dan V. |
last post by:
Situation:
I have to connect with my Windows 2000 server using VS.NET 2003 and C# and
connect to a remote Linux server at another company's office and query their
XML file. Their file may be updated every hour or so. How can I do this
easily? I would like to use secure communication even encryption if
possible. I would query and insert locally only the newest records found in
that XML file to an xml or MS access db.
|
by: lester |
last post by:
a pre-beginner's question:
what is the pros and cons of .net, compared to ++
I am wondering what can I get if I continue to learn C# after I have learned
C --> C++ --> C# ??
I think there must be many know the answer here.
thanks
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode support IDEs are DreamWeaver 8 and
Zend PHP Studio.
DreamWeaver provides full support for Unicode. However, DreamWeaver is
a web editor rather than a PHP IDE. It only supports basic IntelliSense
(or code completion) and doesn't have anything...
|
by: Jason Huang |
last post by:
Hi,
Would someone explain the following coding more detail for me? What's the
( ) for?
CurrentText = (TextBox)e.Item.Cells.Controls;
Thanks.
Jason
|
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
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |