久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

按位運算符簡單地翻轉(zhuǎn)整數(shù)中的所有位?

Bitwise operator for simply flipping all bits in an integer?(按位運算符簡單地翻轉(zhuǎn)整數(shù)中的所有位?)
本文介紹了按位運算符簡單地翻轉(zhuǎn)整數(shù)中的所有位?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我必須翻轉(zhuǎn)整數(shù)二進制表示中的所有位.給定:

I have to flip all bits in a binary representation of an integer. Given:

10101

輸出應(yīng)該是

01010

當與整數(shù)一起使用時,完成此操作的位運算符是什么?例如,如果我正在編寫像 int flipBits(int n); 這樣的方法,那么主體中會發(fā)生什么?我只需要翻轉(zhuǎn)數(shù)字中已經(jīng)存在的內(nèi)容,而不是整數(shù)中的所有 32 位.

What is the bitwise operator to accomplish this when used with an integer? For example, if I were writing a method like int flipBits(int n);, what would go in the body? I need to flip only what's already present in the number, not all 32 bits in the integer.

推薦答案

~ 一元運算符是按位取反.如果您需要的位數(shù)少于 int 中的位數(shù),那么您需要在事后使用 & 對其進行屏蔽.

The ~ unary operator is bitwise negation. If you need fewer bits than what fits in an int then you'll need to mask it with & after the fact.

這篇關(guān)于按位運算符簡單地翻轉(zhuǎn)整數(shù)中的所有位?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 看黄在线 | 91嫩草精品 | 日韩免费三级 | 日本三级电影在线免费观看 | 日韩欧美字幕 | 二区中文| 国产精品亚洲第一区在线暖暖韩国 | 日日操天天射 | 黄色一级大片在线免费看产 | 精品亚洲91 | 精品乱子伦一区二区三区 | 婷婷综合 | 最近最新中文字幕 | 九一视频在线播放 | 久久成人国产 | 日韩一区二区三区在线观看 | 91在线观看视频 | 一级片免费在线观看 | 久久综合一区 | 欧美特级黄色 | 国产精品a久久久久 | 精品视频一区二区 | 亚洲第一区久久 | 亚洲精品一区二区三区四区高清 | 亚洲视频在线观看免费 | 亚洲成人精品 | 国产精品免费在线 | 欧美国产在线一区 | 国产盗摄视频 | 国产欧美一区二区三区国产幕精品 | 中文字幕亚洲一区二区三区 | 欧美日韩一区在线播放 | 在线播放国产一区二区三区 | 久久国产区 | 国产精品久久久久久久午夜 | 视频在线一区二区 | 日本久久久影视 | 亚洲国产精品久久 | 欧美激情久久久久久 | 日韩靠逼 | 激情av |