delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/05/25/06:01:09

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Gerd Termathe" <gerd DOT termathe AT fujitsu-siemens DOT com>
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: <d71i5h$t6h$1@nntp.fujitsu-siemens.com>
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" <rahul DOT h AT gmail DOT com> 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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019