#1
  1. No Profile Picture
    <?php
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Wyoming, USA
    Posts
    41
    Rep Power
    12

    Question bits, bytes, etc...


    hey,

    i am just starting C programming.... and i am having trouble with all this bits and bytes and the range of types and such...

    if someone could help me understand what bits are and how they apply to C programming i would appreciate it :)

    -sean
    "I speak English, can you type it?" -Everett_XML
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    A bit is a singular binary value. That is, one bit is either 0 or 1. On or off. True or false. Ying or yang... So a bit is the smallest possible data unit for a computer.

    A byte is a collection of eight bits. Since one bit can hold 2 values, a byte can hold 2^8 = 256 values, from 00000000 to 11111111 if you use the traditional 0/1 numeric representation.

    That's pretty much it. It isn't really anything specific about C, bits/bytes/etc are really just general computing names.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    36
    Rep Power
    12
    Yeah, and if you want to compare bits you can use bitwise operators. Such as lets say we want 0000 1111 and we want to mask it with 0101 1111 you can use hex and say that 1111 = 15 which equals F and 0101 = 5 so we can have


    0x5F & 0x0F

    would compare the bits.

    EX.

    0101 1111
    &0000 1111
    0101 1111


    Sorry if this confuses you lol but its kinda hard to explain. There is another post about this question try searching for it its called "Bitwise Operators".

    Maybe scorpian or someonne else can help you better.

    Anyways, Hope this helped a lil bit :D

    PS: Oh yea if you are asking why you would need to do this, i have no clue but whatever. :rolleyes:
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,594
    Rep Power
    4207
    >>0101 1111
    >>&0000 1111
    >>---------------------
    >> 0101 1111


    Optix, that's not a bitwise and operation you have described there. That's a bitwise or operation :) 0x5F & 0x0F = 0x0F
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    36
    Rep Power
    12
    oh oops :p

IMN logo majestic logo threadwatch logo seochat tools logo