Home > Net >  The basic problem in several days
The basic problem in several days

Time:12-08

An array of Bytes read from the File byte [] Bytes=File. ReadAllBytes (FileName);
Read from two Bytes and converted into short short type X X=(short) BitConverter. ToInt16 (Bytes, 0)
The above methods through access to relevant data is equivalent to short=X Bytes [0] + (Bytes [1] <8)
I want to know the short=X Bytes [0] + (Bytes [1] <8) what specific principle
If two byte type of number 188 (binary 10111100), 2 (binary 00000010) the correct results for 700
According to the rules of the left shift operator, I can't correct results
Consult the computer specific calculation process (binary)

CodePudding user response:

2 left eight is 1000000000

CodePudding user response:

10111100 (188)
+ 00000010 00000000 (2) left eight, is equivalent to append 8 0
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
00000010, 10111100 (700).

CodePudding user response:

2 left eight is 512
512 + 188=700

The calculator system at the open, switch to programmer mode, carefully to understand it.

CodePudding user response:

A short, there are two bytes, a byte has eight,

Why displacement, like a two decimal integer 99 split into two parts store, for example, became, September 9, if you put the 9 9 back into 99 do? 9 * 10 + 9?

Into binary back into Short, whether or not to move the high part of the left eight bit low plus eight?

CodePudding user response:

reference 1st floor Bridge_go response:
2 left eight is 1000000000

Byte is eight after it left beyond eight

CodePudding user response:

refer to the second floor datafansbj response:
10111100 (188)
+ 00000010 00000000 (2) left eight, is equivalent to append 8 0
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
00000010, 10111100 (700)

Why the left eight automatically become 16

CodePudding user response:

refer to the second floor datafansbj response:
10111100 (188)
+ 00000010 00000000 (2) left eight, is equivalent to append 8 0
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
00000010, 10111100 (700)

I wanted to know why the left eight
And why is the number left was not the first number

CodePudding user response:

refer to 7th floor ljg3081022a response:
Quote: refer to the second floor datafansbj response:
10111100 (188)
+ 00000010 00000000 (2) left eight, is equivalent to append 8 0
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
00000010, 10111100 (700)

I wanted to know why the left eight
And why is the second number left was not the first number


No why, short -- -- -- -- -- -- -- -- -- -- your computer books tell you it is unsigned short plastic, two bytes, this is the rules, no why,
Will be the same as to why the second number is left, high byte what people regulation, low byte put what, this is the byte sequence, byte sequence is not necessarily so, too, of course, there are also big endian and little endian

So you do not exist here who to who wrong, why is there is no second is not the first, just watch the original convention is to use the big endian, or little endian

CodePudding user response:

https://blog.csdn.net/humanking7/article/details/51155778

CodePudding user response:

reference 4 floor icoolno1 response:
a short two bytes, one byte has eight,

Why displacement, like a two decimal integer 99 split into two parts store, for example, became, September 9, if you put the 9 9 back into 99 do? 9 * 10 + 9?

Into binary back into Short, whether or not to move the high part of the left eight bit low plus eight?

Thank you very much
Have a little understand
There are also some problems
How to determine low high? High left low right?
I refer to the code and these parts:
If (X& 0 x8000!=0)
X=X& 0 x7fff;
What is the role of the two lines of code? The code

CodePudding user response:

refer to the eighth floor wanghui0380 response:
Quote: refer to 7th floor ljg3081022a response:
Quote: refer to the second floor datafansbj response:
10111100 (188)
+ 00000010 00000000 (2) left eight, is equivalent to append 8 0
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
00000010, 10111100 (700)

I wanted to know why the left eight
And why is the second number left was not the first number


No why, short -- -- -- -- -- -- -- -- -- -- your computer books tell you it is unsigned short plastic, two bytes, this is the rules, no why,
Will be the same as to why the second number is left, high byte what people regulation, low byte put what, this is the byte sequence, byte sequence is not necessarily so, too, of course, there are also big endian and little endian

So you do not exist here who to who wrong, why is there is no second is not the first, just watch the original convention is to use the big endian, or little endian

Thank you very much
I refer to the code of the following two lines of code
If (X& 0 x8000!=0)
X=X& 0 x7fff;
What effect does this two lines of code

CodePudding user response:

reference 4 floor icoolno1 response:
a short two bytes, one byte has eight,

Why displacement, like a two decimal integer 99 split into two parts store, for example, became, September 9, if you put the 9 9 back into 99 do? 9 * 10 + 9?

Into binary back into Short, whether or not to move the high part of the left eight bit low plus eight?

Seem to see
thank you very muchThank you very much
I refer to the code of the following two lines of code
If (X& 0 x8000!=0)
X=X& 0 x7fff;
What effect does this two lines of code

CodePudding user response:

If (X& 0 x8000!=0)
X=X& 0 x7fff;

It is also a bit operation, and operation, is used to determine, this bad expression, I like the
You have eight lights (8 bit), now I want to decide whether or not one of a few lights on (01001000), so I door USES logic and the nor gate operation to judge him shines or not

CodePudding user response:

references to the tenth floor ljg3081022a response:
Quote: refer to 4th floor icoolno1 response:
a short two bytes, a byte has eight,

Why displacement, like a two decimal integer 99 split into two parts store, for example, became, September 9, if you put the 9 9 back into 99 do? 9 * 10 + 9?
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related