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

為什么二進制表示與 python 編譯器不同,而不是我

Why the binary representation is different from python compiler than what we know on paper?(為什么二進制表示與 python 編譯器不同,而不是我們在紙上所知道的?)
本文介紹了為什么二進制表示與 python 編譯器不同,而不是我們在紙上所知道的?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

Bitwise NOT 是第一個補碼,例如:

Bitwise NOT is the first complement, for example:

  • x = 1(二進制:0001)
  • ~x = -2(二進制:1110)
  • x = 1 (binary: 0001)
  • ~x = -2 (binary: 1110)

因此,我的問題是為什么二進制中的 -2 是 (-0b10) 與 python 編譯器一樣?

Hence, my question is why -2 in binary is (-0b10) as for the python compiler?

我們知道 1110 表示 (14) 代表無符號整數和 (-2) 代表有符號整數.

We know that 1110 represents (14) for unsigned integer and (-2) for signed integer.

推薦答案

二進制補碼本質上取決于數字的大小.例如,有符號 4 位上的 -2 是 1110,但有符號 8 位上是 1111 1110.

Two's complement inherently depends on the size of a number. For example, -2 on signed 4-bit is 1110 but on signed 8-bit is 1111 1110.

Python 的整數類型是任意精度的.這意味著沒有明確定義的前導位來指示負號或二進制補碼的明確長度.二進制補碼是 1...1110,其中 ...1 的無限重復.

Python's integer type is arbitrary precision. That means there is no well-defined leading bit to indicate negative sign or well-defined length of the two's complement. A two's complement would be 1... 1110, where ... is an infinite repetition of 1.

因此,Python 的整數顯示為單獨的符號(無或-)和絕對數字.因此,-2 變為 -0b10 - 即 - 2.同樣,-5 變成 -0b101——即 - 5.

As such, Python's integer are displayed as a separate sign (nothing or -) and the absolute number. Thus, -2 becomes - and 0b10 – i.e. - 2. Similarly, -5 becomes - and 0b101 – i.e. - 5.

請注意,此表示只是人類可讀的標準表示.它不一定是實現定義的內部表示.

Note that this representation is merely the standard representation to be human-readable. It is not necessarily the internal representation, which is implementation defined.

這篇關于為什么二進制表示與 python 編譯器不同,而不是我們在紙上所知道的?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 国产性色视频 | 久久9精品 | 亚洲视频在线免费观看 | 韩日在线观看视频 | 91av小视频| 中文字幕av一区二区三区 | 国产伦精品一区二区三区精品视频 | 久久影音先锋 | 日韩在线观看一区 | 久久国产精品无码网站 | 九色91视频| 精品一区电影 | 欧美电影在线观看网站 | 久久国产精品久久久久久 | 毛片网站在线观看视频 | 久久精品无码一区二区三区 | 成人黄色在线观看 | 欧美视频在线播放 | 日本午夜免费福利视频 | 精品国产91乱码一区二区三区 | 国产精品国产精品国产专区不卡 | 理论片免费在线观看 | 精品视频在线免费观看 | 国产蜜臀 | 日韩一二区 | 91在线免费视频 | 琪琪午夜伦伦电影福利片 | 久久久久久综合 | 超碰在线国产 | 日本成人免费观看 | 精品在线 | 一级片av| www.中文字幕 | 国产福利91精品 | 一级a爱片性色毛片免费 | av在线成人 | 涩爱av一区二区三区 | 最新日韩在线 | 婷婷久久五月 | 久久精品久久久 | 日韩欧美在线一区二区 |