Bytes

This is a discussion on Bytes within the C Programming forums, part of the General Programming Boards category; I have a 4 BYTE array, where a BYTE is an unsigned Char. The last byte is non-effective and so ...

  1. #1
    Unregistered
    Guest

    Question Bytes

    I have a 4 BYTE array, where a BYTE is an unsigned Char. The last byte is non-effective and so is array bit [7]. They have been set to 1 and can be discarded.

    Does anybody have an idea on how to get all possible values for the remaining 22 bits...keeping the 32bit structure in tact as a function expects the full 32bits.

    any ideas please....
    Thank you!!!!

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    ?

    Need more info.

    To find the max value of a number of bits - set all the bits to 1. What are you trying to do?

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm shooting in the dark here, but you know that a long is four bytes right? Why don't you just make these calculations using longs instead of four byte arrays.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    194

    Re: Bytes

    Originally posted by Unregistered
    I have a 4 BYTE array, where a BYTE is an unsigned Char. The last byte is non-effective and so is array bit [7]. They have been set to 1 and can be discarded.

    Does anybody have an idea on how to get all possible values for the remaining 22 bits...keeping the 32bit structure in tact as a function expects the full 32bits.

    any ideas please....
    Thank you!!!!
    A bit has only 2 possible values
    0 or 1 !!!!
    Can you be more specific in your question. I understand that the last byte is not needed, but that would leave 24 bits, not 22.
    Did you make a typo somewhere?

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    You have 4 bytes = 32 bits. As I understand the last byte and bit nr 7 can be discarded so 32 - 8 - 1 = 23 bits left. The maximum value you can get now is 2^23-1 = 8388607.

    Is this what you mean?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reverse Engineering on a Download file
    By c_geek in forum C Programming
    Replies: 1
    Last Post: 03-22-2008, 03:15 PM
  2. Page File counter and Private Bytes Counter
    By George2 in forum Tech Board
    Replies: 0
    Last Post: 01-31-2008, 02:17 AM
  3. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  4. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  5. socket question
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 01:54 PM

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