Thread: a Bit of confusion (haha - Pun)

  1. #1
    Registered User
    Join Date
    Nov 2004
    Location
    Pennsylvania
    Posts
    434

    a Bit of confusion (haha - Pun)

    I'm confused with Bits. I know they are arbitrary as far as length goes which leads to my confusion.

    I'm reading Applied Cryptography (Schneier), and i'm confused as to the size of such things, well not bits i guess but like bytes maybe. I know a char or int on the computer is 8 bits right? Like how would i implement something if i needed, suppose a 4 bit variable?

    And how can i manipulate the bits on a bit-by-bit basis?

    Thanks!
    "Anyone can aspire to greatness if they try hard enough."
    - Me

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    It is hard to find a computer where the int is 8 bit length... Or even impossible - because C-standard require int to be big enough to store 32767 witch require at lease 16 bits

    char is AT LEAST 8 bits long, can be longer...

    for storing 4 bit value you can use or char with masking (you can be sure that you have your 4 bits there, the rest is just ignored) or you use bit-fields making a compiler to chose the appropriate container for it
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bit value check efficiency
    By George2 in forum C Programming
    Replies: 5
    Last Post: 11-05-2007, 07:59 AM
  2. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 08:02 PM
  3. 32 bit v.s. 64 bit
    By xddxogm3 in forum Tech Board
    Replies: 4
    Last Post: 01-14-2005, 09:58 AM
  4. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM
  5. bit conversions
    By wazilian in forum C Programming
    Replies: 4
    Last Post: 10-25-2001, 08:59 PM