Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!nuug!ifi!enag From: enag@ifi.uio.no (Erik Naggum) Newsgroups: comp.lang.c Subject: Re: # to the nth power Message-ID: Date: 3 Nov 90 13:54:27 GMT References: <9750@helios.TAMU.EDU> <1990Nov1.232830.17131@NCoast.ORG> <522@ssp9.idca.tds.philips.nl> <1990Nov2.182217.13958@NCoast.ORG> Sender: enag@ifi.uio.no (Erik Naggum) Organization: Naggum Software, Oslo, Norway Lines: 23 Nntp-Posting-Host: hild.ifi.uio.no In-Reply-To: catfood@NCoast.ORG's message of 2 Nov 90 18:22:17 GMT Originator: enag@hild In article <1990Nov2.182217.13958@NCoast.ORG> catfood@NCoast.ORG (Mark W. Schumann) writes: Spiffy, but it does depend on (exponent & 1) being the same as saying "exponent is odd." Most implementations support this, though. Again, neither solution supports negative exponents. Which are the implementations that doesn't? For all positive integers, you can prove that odd integers have the least significant bit equal to one, and even integers have the least significant bit equal to zero, when represented in binary. Hint: odd, positive integers have a remainder of 1 when divided by 2. For a ones-complement architectures, this even holds for negative integers. Twos-complement architectures will return "odd" for an even negative number in this simple test. Was that what you were thinking of? -- [Erik Naggum] Naggum Software Holmens gt 3, 2nd floor <== NEW! BOX 1570 VIKA / 0118 OSLO / NORWAY <== NEW! --