In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
[1] Original code, complement code and complement code are the coding methods for storing a specific number by the machine.
original code
[2] The original code is the absolute value of the sign bit + the true value, the first bit represents the sign bit, and the remaining bits represent the value.
For example:
An 8-bit binary
0000 0001 (1 original code)
1000 0001 (-1 original code)
8-bit binary representation range is
1111 1111-0111 1111(-127,127)
complement
The complement of a positive number is itself, and the complement of a negative number is based on its original code, with the sign bit unchanged and the rest inverted.
that is
0000 0001 (1 original code)---The complement is the same 0000 0001 (1 complement)
1000 0001 (-1 original code)---inverted code symbol bit unchanged, the rest of the inverted 1111 1110 (-1 inverted code), this number can not see what is represented, need to be converted to the original code to see.
complement
The complement of a positive number or itself,
The complement of a negative number is based on the original code, or the complement of the final +1.
[Summary]
Positive--complement (self)--complement (self)
Negative--complement (sign bit unchanged, rest inverted)--complement (complement +1)
[Example: ]
byte b = (byte) 130;
b = ?
[Analysis]
1. All operations in the computer are complementary.
2, calculate the binary data, 130 (default int type 4 bytes), that is, 1000010 (1 byte)
4-bit byte complement is:
000000 0000000 0000000 1000010 (positive-negative-original)
byte Truncate a byte, i.e.(1000010)---(complement)
3, complement to complement code 1000001
4. Reverse code to original code 1 111110 (-126)
[Expansion]
Here we analyze
byte b = (byte) 130;
b = -126;(byte-128: artificially specified-0 is-128----127)
Which means it's a loop, which means
127(127)
128 (-128)
129(-127)
130(-126)
131(-125)
.....
400(-112)
Calculation idea:
From-128--127 to 256
400-256=144(-112)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.