Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3189

Re: Bit wise Operators in SQL Script

$
0
0

Hi Goutham,

 

You have this bitwise functions available (check SAP HANA SQL and System Views Reference for details) :

 

BITAND

BITCOUNT

BITNOT

BITOR

BITSET

BITUNSET

BITXOR

 

As far as I know there are no shift operators or functions available, but a workaround you can use is to multiply or divide and then truncate (if necessary depending on your exact numeric type) your values by powers of 2.  Multiplying is equivalent to left-shifting and dividing/truncating is equivalent to right-shifting.

 

For example:

 

- If you want to left-shift x three positions, apply x*8  (8 is the result of 2^3)

- If you want to right-shift x one position, apply FLOOR( x/2 )  (2 is the result of 2^1)

 

Regards,

Fernando


Viewing all articles
Browse latest Browse all 3189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>