触发输出一点一点

编程入门 行业动态 更新时间:2024-10-26 13:20:06
本文介绍了触发输出一点一点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

更多推荐

触发输出一点一点

本文发布于:2023-07-05 06:51:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034341.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!