0

So i want to XOR on hexadecimal so i do this

select X'4e20' # X'4521'; --the output is 0000101100000001

but the thing is i wanna do XOR binary with hexa or integer with hexa or integer with binary, so i try to do this

select X(select to_hex(6700::bit(16))) # X'4F21';

this query will produce error result

[Err] ERROR:  syntax error at or near "select"
LINE 2: select X(select to_hex(6700::bit(16))) # ...

So how can i do this that? and is it possible to xor an Ascii on postgresql? and i want to know how to :

1.convert binary to integer

2.convert hexa to binary vice versa

3.convert hexa to integer

4.conver ascii to integer

this is Bit String Functions and Operators official from postgresql https://www.postgresql.org/docs/9.4/static/functions-bitstring.html

1 Answer 1

1

If you want the output to be a bit value, you should cast the integer to bit:

test=> SELECT 6700::bit(16) # X'4F21';

     ?column?     
------------------
 0101010100001101
(1 row)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.