Cade Cairns wrote:
When casting a bit string constant using hexadecimal notation to a longer
bit string, the result is padded with 0's on the right. This will result in
inconsistent/useless results:

test=# select x'ff'::integer;
int4 ------
  255
(1 row)

test=# select x'ff'::bit(16)::integer;
int4 -------
 65280
(1 row)

It works like it should according to the manual:

http://www.postgresql.org/docs/8.1/interactive/datatype-bit.html

"Note: If one explicitly casts a bit-string value to bit(n), it will be truncated or zero-padded on the right to be exactly n bits, without raising an error. Similarly, if one explicitly casts a bit-string value to bit varying(n), it will be truncated on the right if it is more than n bits."

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match

Reply via email to