a little code need to explain
-
last time,one administrator of this forum tell me study C++ need to work by myself.i know.....and i can taste your angry gas.but some problem need to be solved,although it is a little problem.also i can't find a answer in the MSDN. if you don't have time,please don't be care at me.if someone have love and time,please help me.the question is : ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8)) how do i understand it?
-
last time,one administrator of this forum tell me study C++ need to work by myself.i know.....and i can taste your angry gas.but some problem need to be solved,although it is a little problem.also i can't find a answer in the MSDN. if you don't have time,please don't be care at me.if someone have love and time,please help me.the question is : ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8)) how do i understand it?
-
last time,one administrator of this forum tell me study C++ need to work by myself.i know.....and i can taste your angry gas.but some problem need to be solved,although it is a little problem.also i can't find a answer in the MSDN. if you don't have time,please don't be care at me.if someone have love and time,please help me.the question is : ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8)) how do i understand it?
The best way to understand code is usually to break it into smaller parts until they're simple enough to understand. Let's see
( (WORD) ( ( (BYTE)(a) ) | ( (WORD) ( (BYTE)(b) ) ) << 8 ) )
which is like((WORD)( x ))
meaning cast x to a WORD (usually 2 byte integer type, check withsizeof(WORD);
) where x is y | z << 8 where y is (a) cast to a BYTE (usually 8 bit unsigned) and z is b cast to a BYTE and then cast to a WORD. Basically pair up the brakets and break down the expression into its parts, good luck :)Nothing is exactly what it seems but everything with seems can be unpicked.
-
The best way to understand code is usually to break it into smaller parts until they're simple enough to understand. Let's see
( (WORD) ( ( (BYTE)(a) ) | ( (WORD) ( (BYTE)(b) ) ) << 8 ) )
which is like((WORD)( x ))
meaning cast x to a WORD (usually 2 byte integer type, check withsizeof(WORD);
) where x is y | z << 8 where y is (a) cast to a BYTE (usually 8 bit unsigned) and z is b cast to a BYTE and then cast to a WORD. Basically pair up the brakets and break down the expression into its parts, good luck :)Nothing is exactly what it seems but everything with seems can be unpicked.
-
youbo wrote:
chariness
I don't even want to know what that could mean. :)
Chris Meech I am Canadian. [heard in a local bar] Donate to help Conquer Cancer[^]
-
youbo wrote:
chariness
I don't even want to know what that could mean. :)
Chris Meech I am Canadian. [heard in a local bar] Donate to help Conquer Cancer[^]
It's the opposite of "angry gas" :)
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
It's the opposite of "angry gas" :)
Mark Salsbery Microsoft MVP - Visual C++ :java:
:laugh:
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
youbo wrote:
chariness
I don't even want to know what that could mean. :)
Chris Meech I am Canadian. [heard in a local bar] Donate to help Conquer Cancer[^]
I think 'Chairness' would be the measurement unit used to find out your ability to sit in a chair. :laugh:
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP