delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/10/09:50:08

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Message-Id: <199707101349.AA237002579@typhoon.rose.hp.com>
Subject: Re: your ma
To: chirayu AT giasbga DOT vsnl DOT net DOT in (Chirayu Krishnappa)
Date: Thu, 10 Jul 1997 6:49:39 PDT
Cc: djgpp AT delorie DOT com
In-Reply-To: <Pine.SV4.3.93.970710151909.18181A-100000@giasbga>; from "Chirayu Krishnappa" at Jul 10, 97 3:21 pm

> i need to find out if a 4 byte (default) integer has an even number of 1's
> in its binary representation or not. I need to operate on 15Mb data and do
> it fast. shifts (<<) and & is quite slow. is there some lib. function to
> do this? what is the fastest way to get it done?

The only way I can think of to do this is to use the parity flag
(Pentiums still have that  - right :).  I think (really not sure here),
that if you so hat a bit of inline assembly that does an OR of the value 
with itself and the a jump on parity that should do the trick.

HTH 

Andrew

- Raw text -


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