a Bit of confusion (haha - Pun)

This is a discussion on a Bit of confusion (haha - Pun) within the C++ Programming forums, part of the General Programming Boards category; I'm confused with Bits. I know they are arbitrary as far as length goes which leads to my confusion. I'm ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

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-26-2001, 12:45 AM
  5. bit conversions
    By wazilian in forum C Programming
    Replies: 4
    Last Post: 10-25-2001, 09:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21