Subject: Re: 2s complement
To: Chapman Flack <nblists@anastigmatix.net>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 01/06/2006 18:23:49
--da4uJneut+ArUgXk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jan 06, 2006 at 08:52:25PM -0500, Chapman Flack wrote:
> Rui Paulo wrote:
> >On 2006.01.06 14:06:54 -0500, Chapman Flack wrote:
> >| Are there any current or contemplated NetBSD ports to
> >| non-2s-complement machines?
> >
> >No, I don't think so.
>=20
> ok ... I wondered because I wasn't sure why bit_ffs in bitstring(3) is
> done with a per-bit for loop, and thought maybe it meant 2s complement
> techniques would be making too much of an architecture assumption.
> Does anyone know of a reason not to use x^(x-1) in NetBSD code?

Because I don't see how x^(x-1) will give you the first bit set. :-)

I've tried plugging in some numbers, and I don't see how we can use=20
exclusive-or math instead of a for loop. I do see how we could make it=20
O(log # bits in byte), but that's O(8) vs O(3)...

Take care,

Bill

--da4uJneut+ArUgXk
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFDvyY1Wz+3JHUci9cRApqNAJ0bpij4OMnZwSqPxylWfJklZZ3u5gCePkhx
0JTY2SimHbGWDdDDs0bFqaU=
=rf5+
-----END PGP SIGNATURE-----

--da4uJneut+ArUgXk--