Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. a little code need to explain

a little code need to explain

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelpc++
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    youbo
    wrote on last edited by
    #1

    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?

    C M 2 Replies Last reply
    0
    • Y youbo

      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?

      C Offline
      C Offline
      chandu004
      wrote on last edited by
      #2

      putting the byte b in msb and a in lsb of a word. is not it?

      1 Reply Last reply
      0
      • Y youbo

        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?

        M Offline
        M Offline
        Matthew Faithfull
        wrote on last edited by
        #3

        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 with sizeof(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.

        Y 1 Reply Last reply
        0
        • M Matthew Faithfull

          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 with sizeof(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.

          Y Offline
          Y Offline
          youbo
          wrote on last edited by
          #4

          thanks for your chariness

          C 1 Reply Last reply
          0
          • Y youbo

            thanks for your chariness

            C Offline
            C Offline
            Chris Meech
            wrote on last edited by
            #5

            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[^]

            M R 2 Replies Last reply
            0
            • C Chris Meech

              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[^]

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              It's the opposite of "angry gas" :)

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              R 1 Reply Last reply
              0
              • M Mark Salsbery

                It's the opposite of "angry gas" :)

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #7

                :laugh:

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                1 Reply Last reply
                0
                • C Chris Meech

                  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[^]

                  R Offline
                  R Offline
                  Rajesh R Subramanian
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups