# 22. Virtuoso Functions Guide - bit_shift

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
abs
atof
bit_and
bit_not
bit_or
bit_shift
bit_xor
ceiling
either
equ
exp
floor
isdouble
isfloat
isinteger
isnumeric
iszero
log
log10
lower
mod
power
randomize
rnd
sign
sqrt
trigonometric
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## bit_shift

Returns the result of bitwise shift opertion over two 32-bit integers.
bit_shift (in value integer, in distance integer);
Description

The function returns bitwise shift of two given integers. Depending on the arguments, the shift may be left or right. For right-shift, leftmost bits of the result are filled by the value of the 31-st bit.

On 64-bit platforms, both arguments are intentionally truncated to 32 bits and the shift is restricted to 32 bits to maintain compatibility.

Parameters
value – The value to be shifted.
distance – The sign of the parameter specifies the direction of the shift: positive values indicate shift to the left, negative values indicate shift to the right. The absolute value of the parameter specifies the number of bits to shift. The value of zero means that the result is equal to the value of the first argument.
Return Types

Integer.

Examples
Bitwise-shifting

    select bit_shift (18, 6);
    1152

    select bit_shift (-18, 6);
    -1152

    select bit_shift (1152, -6);
    18

    select bit_shift (-1152, -6);
    -18

See Also

bit_and

bit_or

bit_not

bit_xor