The shift operations include "logical Shift" (logical shift) and "arithmetic Shift" (arithmetic shift).Logical shift: bit discarded, vacant bit (vacant bit) filled with 0.Arithmetic shift
Binary conversion to BCD usually uses the division operation to find Bits, 10, hundred, and other positions on the number, but because of the division of the module occupies too much resources, and when the number of binary digits, the use of assembly language in the 8-bit 51 single-chip microcomputer is difficult to achieve, so commonly used plus three shift met
Shift Operator: The most important point, although the digital storage in the computer memory is in the 2-based complement form, but the use of the shift operator is the source code.
← Shift Operator: High Discard, low 0 (negative numbers are the same as positive)
Example: int a=-10,g. g=a
→ shift operator: The sign bi
In a computer, the number of symbols is represented by a complement.
1. Original code
The first digit of the original code is the symbol bit, and the other digits represent the value. For example, 8-bit binary:
[+ 1] original = 0000 0001
[-1] original = 1000 0001
2. Supplemental code
The positive complement is itself. The negative complement is based on the original code, and the symbol bit remains unchanged. The rest are reversed by + 1.
[+ 1]
2015-09-17 10:57:12////////////////////////////////////////////////////////////////////////////in binary shift operation, the byte size of the shifted number determines whether the shift will overflow//////////////////////////////////////////////////////////////////////////#include #includeintMain () {Long LongNumber0), Number2 (0); intPos +); number|=1(POS); Num
When you need a simple calculation, you do not want to use the GUI calculator, can be directly calculated under the shell is the bestChecked, there is a thing called BC, the specific use will not repeat, you can run BC, and then go into the calculation, you can echo the past, probably like thisEcho " 1+2 " | BC Echo " ibase=16;1a+1 " | BcHowever, it is not easy to use, the first is to specify the system, so that the entire expression is this type of,
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.