~ (Bitwise Unary NOT) (TSQL Operator)
Returns the bitwise NOT value of an integer.
Syntax
~ expression
Arguments
- expression
- is a numeric expression of type
bit
,tinyint
,smallint
,int
,bigint
.
Return Types
Returns the same datatype as expression.
Examples
-- binary representation of 125 is 00000000 00000000 00000000 01111101
-- binary representation of ~125 is 11111111 11111111 11111111 10000010 (-126)
PRINT ~125;
The result is:
-126