X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Gerd Termathe" Newsgroups: comp.os.msdos.djgpp Subject: Re: to check given no. is power of 2 Date: Wed, 25 May 2005 11:58:34 +0200 Organization: Fujitsu Siemens Computers GmbH Lines: 16 Message-ID: References: <1116997063 DOT 905915 DOT 71670 AT z14g2000cwz DOT googlegroups DOT com> NNTP-Posting-Host: abg2212c.abg.fsc.net X-Trace: nntp.fujitsu-siemens.com 1117015025 29905 172.25.145.1 (25 May 2005 09:57:05 GMT) X-Complaints-To: abuse AT sbs DOT de NNTP-Posting-Date: Wed, 25 May 2005 09:57:05 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "aveo" schrieb im Newsbeitrag news:1116997063 DOT 905915 DOT 71670 AT z14g2000cwz DOT googlegroups DOT com... > hi all > i need a C code that checks given no. is power of 2 or not without > checking any condition. > int is_power_of_2 (int N) { if ( N!=0 && (N&(N-1))==0 ) return 1; else return 0; } Gerd