Subject: Re: 2s complement
To: None <tech-kern@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 01/09/2006 09:58:10
>>> Are there any current or contemplated NetBSD ports to
>>> non-2s-complement machines?
>> No, I don't think so.

At least not assuming you're talking about integer arithmetic; there
are many if you allow floating point.  (Most floating-point computer
arithmetics, including both IEEE and VAX, are sign-magnitude - I don't
think we have anything but the VAX that doesn't do IEEE float, do we?)

> 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.

My opinion would be that they would not.  NetBSD already makes
architecture assumptions which are significantly more restrictive in
practice, like assuming that nil-pointer is all-bits-zero.

> Does anyone know of a reason not to use x^(x-1) in NetBSD code?

Not me, especially not since I think C's bitwise operations are defined
to operate as if the machine were two's-complement binary, whether it
actually is or not.  (Yes, this means C is a bad language for use on
machines that aren't 2's-c binary....)

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B