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. Reading specific bit values from a file.

Reading specific bit values from a file.

Scheduled Pinned Locked Moved C#
data-structurestutorialquestion
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.
  • J Offline
    J Offline
    Jim Taylor
    wrote on last edited by
    #1

    How can I read a specific bit or series of bits (as a bit array) from a file. I can use a file stream and binary reader to get specific bytes but I do not know how to easily convert this into a bit array (at least not very efficiently). Jim

    C 1 Reply Last reply
    0
    • J Jim Taylor

      How can I read a specific bit or series of bits (as a bit array) from a file. I can use a file stream and binary reader to get specific bytes but I do not know how to easily convert this into a bit array (at least not very efficiently). Jim

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      To turn a byte into bits, bool is the most obvious choice ( the only one I can think of with 2 states ) and you & the value with 0x1, 0x2, 0x4, 0x8, ox10, etc to strip the bits. I reckon this is what you've thought of, but I don't know of any more efficient way, excepting that I'd be more inclined to do this when I need the value, and not store it as bits in memory. Christian Graus - Microsoft MVP - C++

      J 1 Reply Last reply
      0
      • C Christian Graus

        To turn a byte into bits, bool is the most obvious choice ( the only one I can think of with 2 states ) and you & the value with 0x1, 0x2, 0x4, 0x8, ox10, etc to strip the bits. I reckon this is what you've thought of, but I don't know of any more efficient way, excepting that I'd be more inclined to do this when I need the value, and not store it as bits in memory. Christian Graus - Microsoft MVP - C++

        J Offline
        J Offline
        Jim Taylor
        wrote on last edited by
        #3

        I still wonder if there's a quicker way - but speed is not essential for what I am doing - reading mp3 header information. Jim

        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