Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UiaEA-0002ej-OY for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Jun 2013 01:03:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UiaEA-0006uX-4e for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Jun 2013 01:03:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UiaE8-0006uP-7i for pgsql-bugs@postgresql.org; Sat, 01 Jun 2013 01:03:24 +0000 Received: from mbx.knossos.net.nz ([202.160.48.10]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UiaDt-0002sU-MC for pgsql-bugs@postgresql.org; Sat, 01 Jun 2013 01:03:23 +0000 Received: from [10.1.1.3] (60-234-150-59.bitstream.orcon.net.nz [60.234.150.59]) (authenticated bits=0) by mbx.knossos.net.nz (8.14.4/8.14.4) with ESMTP id r511150g019691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 1 Jun 2013 13:01:06 +1200 Message-ID: <51A947D1.50205@archidevsys.co.nz> Date: Sat, 01 Jun 2013 13:01:05 +1200 From: Gavin Flower Organization: ArchiDevSys User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: John R Pierce CC: pgsql-bugs@postgresql.org Subject: Re: BUG #8191: Wrong bit conversion References: <11097.1370036031@sss.pgh.pa.us> <7A3A36FE51533446AAB1EA0F6069AC8C40A5B460@HEXBOSSSERVER.hexboss.local> <51A9406B.9040908@hogranch.com> In-Reply-To: <51A9406B.9040908@hogranch.com> Content-Type: multipart/alternative; boundary="------------010805030804040303050700" X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is a multi-part message in MIME format. --------------010805030804040303050700 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 01/06/13 12:29, John R Pierce wrote: > On 5/31/2013 4:29 PM, Gerald Luger wrote: >> Shouldn't I expect all results to be 000...0001? >> >> Otherwise it would be >> 1 != 1? > > SQL's BIT type is big endian, a hangover from its IBM mainframe heritage. > > > > > I don't think it has anything to do with byte sex (I know of 3 ways to store integers in memory, and I suspect there are more !). Don't confuse how things are displayed with how they are stored in memory. Just that 1 = two to the power of zero so it seems logical to start numbering the bits to represent the powers of 2. Cheers, Gavin --------------010805030804040303050700 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 01/06/13 12:29, John R Pierce wrote:
On 5/31/2013 4:29 PM, Gerald Luger wrote:
Shouldn't I expect all results to be 000...0001?

Otherwise it would be
1 != 1?

SQL's BIT type is big endian, a hangover from its IBM mainframe heritage.





I don't think it has anything to do with byte sex (I know of 3 ways to store integers in memory, and I suspect there are more !).

Don't confuse how things are displayed with how they are stored in memory.

Just that
    1 = two to the power of zero
so it seems logical to start numbering the bits to represent the powers of 2.


Cheers,
Gavin
--------------010805030804040303050700--