使用按位移位运算符 [英] Use of Bitwise shift operators

查看:127
本文介绍了使用按位移位运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按位移位运算符有什么用?意味着我们在应用程序中可以使用哪些?

What is the use of bitwise shift operators?Means where can we use in application?

推荐答案

Sean Eron Anderson有一个很好的比特扭曲黑客 [ ^ ]说明了它们的用处。



问候

Espen Harlinn
Sean Eron Anderson has a nice collection of Bit Twiddling Hacks[^] that illustrates their usefulness.

Regards
Espen Harlinn


下面两个链接中的一个很好的解释。可能对你非常有用。

http ://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/bitshift.html



另一个

http://stackoverflow.com/questions/141525/absolute-beginners-引导到位移位
A well explanation in two links below. May be it is very usefull for you.
http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/bitshift.html

another one
http://stackoverflow.com/questions/141525/absolute-beginners-guide-to-bit-shifting


有两种类型的按位运算符 - >

1:左移位运算符 - <<

2:右移操作员 - >>



左移操作员: -

使用它在左侧移动,但取决于你指定要移动的长度。

示例 - 我的号码是-8,我想把它移到左边2个地方

首先计算8的二进制,当你应用左移时

,长度为2时,它将是-1000,意味着你想要左移2位,那么它将左移r二进制格式如-100000和现在你的o / p将是100000的十进制意味着(32)



右Shif算子: - 相同的1000将是,右移长度为2的运算符将变为-0000表示(2)
there are two types of bitwise operator->
1:Left Shift Operator- <<
2:Right Shift Operator- >>

Left Shift Operator:-
It is used to shift at left side,but depends on the length u will specify to shift.
Example- My number is-8,I want to shift it 2 place at left
First calculate binary of 8,it will be-1000 when u apply left Shift
with the lengthh of 2,means u want to left shift 2 place,then it will left shift ur binary format like- 100000 and now ur o/p will be decimal of 100000 means (32)

Right Shif Operator:- Same 1000 will be,with right shift operator with length 2 will become-0010 means (2)


这篇关于使用按位移位运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆