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. INT to Binary

INT to Binary

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

    Does anybody know of a way to convert an INT to it binary representation? i.e. 85 = 1010101 56 = 0111000 and so on post.mode = postmodes.signature; SELECT everything FROM everywhere WHERE something = something_else; > 1 Row Returned > 42

    P M 2 Replies Last reply
    0
    • M MrEyes

      Does anybody know of a way to convert an INT to it binary representation? i.e. 85 = 1010101 56 = 0111000 and so on post.mode = postmodes.signature; SELECT everything FROM everywhere WHERE something = something_else; > 1 Row Returned > 42

      P Offline
      P Offline
      PJL
      wrote on last edited by
      #2

      Try checking out the System.Collections.BitArray class; it provides a pretty decent way of looking at/manipulating integers at the bit-level. I've used it a few times for win32 and mp3 stuff. Also, if you only want to check the presence/abscence of a particular bit, use the '&' bitwise operator. I've found it's extremely worthwhile to truly understand the bit-level operators, especially if you're doing those type of operations frequently.

      1 Reply Last reply
      0
      • M MrEyes

        Does anybody know of a way to convert an INT to it binary representation? i.e. 85 = 1010101 56 = 0111000 and so on post.mode = postmodes.signature; SELECT everything FROM everywhere WHERE something = something_else; > 1 Row Returned > 42

        M Offline
        M Offline
        Michael Flanakin
        wrote on last edited by
        #3

        int intSomeNumber = 999;
        string strBits = Convert.ToString( intSomeNumber, 2 );

        Michael Flanakin Web Log

        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