久久久久久久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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 精品一区在线 | 自拍视频国产 | 欧美一级欧美三级在线观看 | 欧美一区2区三区3区公司 | 欧美一级免费黄色片 | av播播| 一级毛片免费完整视频 | 欧美日韩在线观看视频网站 | 中文字幕 亚洲一区 | 久久国产精品视频观看 | 国产一级片在线观看视频 | 欧美三区| 久草www| 国产1区2区3区 | 亚洲精品白浆高清久久久久久 | 久久国产精品免费一区二区三区 | 精品欧美一区二区久久久伦 | 亚洲永久免费观看 | 羞羞视频网站 | 国产一区二区三区在线 | 日韩2020狼一二三 | 欧美一区二区三区在线播放 | 国产丝袜av | 久久国产精品99久久久大便 | 国产一级一级 | 国产99久久精品一区二区300 | 久久久久久久久久久久91 | 久久久精品国产 | 99久久免费精品视频 | 欧美成人第一页 | 午夜精品久久久久久久久久久久久 | 欧美一区二区在线播放 | 久久99国产精品 | 日本不卡免费新一二三区 | 四虎影视免费在线 | 日本黄色大片免费 | 玖玖爱365| www.久久久久久久久久久久 | 中文字幕在线欧美 | 亚洲免费一 | 欧美激情一区二区三级高清视频 |