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

按位運算符簡單地翻轉整數中的所有位?

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

問題描述

我必須翻轉整數二進制表示中的所有位.給定:

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

10101

輸出應該是

01010

當與整數一起使用時,完成此操作的位運算符是什么?例如,如果我正在編寫像 int flipBits(int n); 這樣的方法,那么主體中會發生什么?我只需要翻轉數字中已經存在的內容,而不是整數中的所有 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.

推薦答案

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

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.

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

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

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
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 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 欧美a区 | 日韩www | 2022精品国偷自产免费观看 | 一级a毛片| www.中文字幕av | 国产精品乱码一区二三区小蝌蚪 | 国产高清久久 | 久久久久国产 | 日韩精品一区二区三区视频播放 | 亚洲精品麻豆 | 手机三级电影 | 亚洲 中文 欧美 日韩 在线观看 | 成人国产精品久久久 | 国产网站在线免费观看 | 久久一区精品 | a爱视频| 中文字幕电影在线观看 | 亚洲狠狠爱 | 日韩看片 | 男女爱爱福利视频 | 国产96在线 | 国产高清一区 | 欧美亚洲视频 | 成人黄色av网站 | a国产视频 | 日韩精品一二三 | 请别相信他免费喜剧电影在线观看 | 999国产视频| 欧美一级毛片久久99精品蜜桃 | 亚洲一av| 亚洲欧美综合网 | 西西裸体做爰视频 | 亚洲精品黑人 | 国产精品久久久久久模特 | 日韩国产一区二区三区 | 黄色国产在线播放 | 日日操夜夜操天天操 | 国产精品亚洲精品 | 在线婷婷 | 国产一区二区成人 | 久草精品视频 |