参考链接:http://dataeducation.com/bitmask-handling-part-4-left-shift-and-right-shift/

 

  SQL Server 官网的连接:https://docs.microsoft.com/zh-cn/sql/t-sql/language-elements/bitwise-operators-transact-sql?view=sql-server-2017

 

   C#MSDN文档说明: https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/index

 

C#代码的

移位运算符

这些运算符的优先级比下一章节高,比上一章节低。

x << y:左移位,右侧用 0 填充。

如果左操作数是 uint 或 ulong,则左位数补零。

 

 

SQL Server 的  移位运算符处理

a << b = a * power(2, b)
a >> b = a / power(2, b)

 

 

SELECT
CAST(0xFF * POWER(CAST(256 AS BIGINT), 0) AS BINARY(12)) AS Shift0,
CAST(0xFF * POWER(CAST(256 AS BIGINT), 1) AS BINARY(12)) AS Shift1,
CAST(0xFF * POWER(CAST(256 AS BIGINT), 2) AS BINARY(12)) AS Shift2,
CAST(0xFF * POWER(CAST(256 AS BIGINT), 3) AS BINARY(12)) AS Shift3,
CAST(0xFF * POWER(CAST(256 AS BIGINT), 4) AS BINARY(12)) AS Shift4,
CAST(0xFF * POWER(CAST(256 AS BIGINT), 5) AS BINARY(12)) AS Shift5

 

相关文章:

  • 2021-06-13
  • 2022-12-23
  • 2021-08-31
  • 2021-11-20
  • 2021-05-15
猜你喜欢
  • 2021-08-28
  • 2021-08-08
  • 2021-08-08
  • 2022-01-01
  • 2021-05-24
相关资源
相似解决方案