Search code examples
postgresqltypescastingbitwise-operators

Cast bit(64) to boolean in Postgres


I know you can cast an int8 to a boolean like so:

int8::int4::boolean

Now I'm trying to cast an int8 to a bit(64), AND that with a bit(64) mask, and then evaluate the entire expression as a boolean (ie. true iff at least one bit is 1).

But bit(64)::int4::boolean doesn't work.

What does?


Solution

  • I see no need for that, since there are bit-wise ooerators:

    WHERE intcol & 127 <> 0