delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/12/17:29:28

Date: Sat, 12 Jul 1997 14:28:56 -0700 (PDT)
Message-Id: <199707122128.OAA11763@adit.ap.net>
Mime-Version: 1.0
To: "Liam" <marl AT rmplc DOT co DOT uk>
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: odd or even # of 1's (was: no subject)
Cc: djgpp AT delorie DOT com

At 03:35  7/12/1997 +0100, you wrote:
>To find out if a value is odd or even all you have to do is check the first
>bit, bit 0.
That wasn't the question. The original poster wanted to find whether there
were an odd or even number of *1 bits* in an int (wanted to know its
parity). Ie, this number:
 01110001010111001101010111001010b
has 17 1-bits in its binary representation, hence it has odd parity. Even
though it is an even number.


Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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