Subject | Re: [firebird-support] How to invert a bitmask? |
---|---|
Author | Paul Vinkenoog |
Post date | 2010-05-10T02:49:33Z |
Michael Ludwig wrote:
complement format, this is always -1. For unsigned numbers, this is
2^n - 1 (with n the number of bits).
So, Firebird's INTEGER and BIGINT being signed, BIN_XOR(number, -1)
should do the trick. Do test it, though!
HTH,
Paul Vinkenoog
> How can I invert a bitmask in Firebird/PSQL (such as with ~ in Perl)?XOR with a number where all the bits are 1. For signed numbers in two's
complement format, this is always -1. For unsigned numbers, this is
2^n - 1 (with n the number of bits).
So, Firebird's INTEGER and BIGINT being signed, BIN_XOR(number, -1)
should do the trick. Do test it, though!
HTH,
Paul Vinkenoog