触发输出一点一点 [英] trigger output bit by bit

查看:82
本文介绍了触发输出一点一点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我看到了一个演示代码,通过使用这两个符号,可以将触发输出的功能从一个字节一个字节地变为另一个字节,
| =和&=
我不知道它的功能是什么..导致我无法从google〜

hello, i saw a demo code which change the function of trigger output from byte by byte to bit by bit, by using both of this symbol,
|= and &=
i wonder what is the function of it.. cause i cant find any solution from google~

推荐答案



要设置x,请使用以下功能:
Hi,

to set a bit x, use this functionality:
number |= 1 << x;


要清除x,请使用以下代码:


to clear a bit x, use this code:

number &= ~(1 << x);


要切换x,请使用以下代码:


to toggle a bit x, use this code:

number ^= 1 << x;


请参阅此处以获得说明:
http://www.cprogramming.com/tutorial/bitwise_operators.html [


See here for an explanation:
http://www.cprogramming.com/tutorial/bitwise_operators.html[^]


这篇关于触发输出一点一点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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