C # Base Egg pain to burst byte type table number range of net sweater insights ...

Source: Internet
Author: User

In fact, write this article on the range of byte type table, really is the egg pain + egg pain + egg pain, often see the range of byte table this piece. All to 128 so strange and confused. Fucking byte, fucking life ...

Bear Boy Appearances: Byte

Prank results: Number of tables range ( -128-------127)

The reason for the egg ache: on a not very good university, in the computer composition principle class. The teacher also in the original code, anti-code, the complement of the journey ...

Determined to be a man again: before there was a byte in front of me let me go to love her, but I did not cherish, assuming God gave me another blog, I decided to say to her: "I will write for you 10,000 times ..."

1) The difficulty is why the number of tables ranges from -128-----127? Don't understand. Do not understand, still do not understand.

127 Good understanding. Is 01111111, but why-128 is 10000000??? What's your mother's bottom?

2) Let's talk about some of my personal ideas (big god please step on me to participate and discuss)

One: Poor lifting

BYTE eight-digit poor lift is too complex. Example three-bit binary.

100,101. 110,111,000,001,010. 011. The number of tables with a range of 2 is 8. (Note that 100 here is equivalent to 10000000 of the byte-poor lifting)

Since all the numbers in the computer are represented in the form of a complement. So 100,101. 110,111,000,001,010,011 is full complement.

Look at the positive number first: the decimal of 000 is 0. 001 of the 1,010 is 2. 011 is 3. That is, the positive range of the three-bit binary is 0,1,2,3.

Then look at the complement of negative numbers: 100,101,110,111. (The key comes, I hope colleagues to look at it)

The decimal number for 101 is-3,110 for-2,111 for-1

Look at 100! again.

According to the poor lift. 100 can only represent-4.

The sample goes to byte. A positive byte range is expressed as 0----127 (00000000------01111111). Negative range represented as 128 to -1 (10000000------11111111)

Second: Discussion of 10000000 Why is the representative-128?

Someone said, you do not front of the 8-bit binary poor to calculate the 10000000 is-128? That's true. But if we calculate it with our great original code, anti-code, and complement, it's more convincing.

The following is the number of the decimal number to start the complement 10000000. ( the symbol bit 1 is the same as normal.) The remaining 7 digits are reversed and then the bottom plus 1 is the original code. It's still 10000000 to be counted. is the decimal number-0? )

It was a pity. At least on our earth there is no negative 0 of this claim. So how does 10000000 figure out the 128?

The calculation process: retain the sign bit 1, the remaining 7 bits 0000000 take the inverse plus 1 is 10000000, plus the sign bit 1, the last source code is 110000000, but there is a rule in the calculation. is beyond the 8-bit part of their own initiative to discard, so it becomes 10000000, 128, the result is a positive value of 128. But the original 10000000 was negative, or 128.

Work it out ...

(Correct the error ...) In C #. SByte represents a signed 8-bit integer type, and byte represents an unsigned integer type. So here ... The above discussion of -128~127 is only for sbyte data types, remember.

! )


C # Base Egg pain to burst byte type table number range of net sweater insights ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.