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#
  4. Spliting short to 2 bytes

Spliting short to 2 bytes

Scheduled Pinned Locked Moved C#
3 Posts 2 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.
  • D Offline
    D Offline
    Dwayner79
    wrote on last edited by
    #1

    I need to split MSB and LSB from a short. Thanks in advance.

    ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

    D B 2 Replies Last reply
    0
    • D Dwayner79

      I need to split MSB and LSB from a short. Thanks in advance.

      ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

      D Offline
      D Offline
      Dwayner79
      wrote on last edited by
      #2

      Nevermind: http://msdn2.microsoft.com/en-gb/library/system.bitconverter.getbytes.aspx

      ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

      1 Reply Last reply
      0
      • D Dwayner79

        I need to split MSB and LSB from a short. Thanks in advance.

        ***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW

        B Offline
        B Offline
        bankai123
        wrote on last edited by
        #3

        A alternative is to use bit shifting. To get the MSB you could shift the bits right by 15. eg msb = short >> 15; To get the LSB you can always use a bit mask, by using the bitwise AND operator on the short. eg. lsb = short & 0x0001;

        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