@don: so if a 16bit value is put into a 32 bit field and i need to read the value, do i need to read last 16 bits only somehow ?
On Wed, Aug 24, 2011 at 8:22 PM, Don <[email protected]> wrote: > It is most common to use 4 bytes to store an integer value, even if > the full range will not be used. There is no problem putting a 16-bit > value into a 32-bit field. The only case where this is not true is > when memory is extremely limited and you need to pack as much into > every word as possible. Do be aware that most structures are word- > aligned, so to actually save memory you must have several adjacent > elements in the structure which can be combined into one word. > Don > > On Aug 24, 1:07 pm, Arun Vishwanathan <[email protected]> wrote: > > Hi all, > > > > I need to store a hexadecimal value in C( which would be used as a > request > > type in a network) of around 4digits( or 16 bits-2 bytes ) in a packet > > structure.If my system keeps 4 bytes for an integers, is it necessary > that I > > have to declare the hex value as of type short int or so, so that it > takes > > up only 2 bytes in my packet ? What if it was required to have a hex > value > > of 3 bytes or so? How could i store it then? > > Also if hex value was to be of a multiple of 4 bytes would i need to use > > something like an integer array to store them or a float maybe? > > > > thanks! > > > > -- > > "People often say that motivation doesn't last. Well, neither does > bathing > > - that's why we recommend it daily." > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- "People often say that motivation doesn't last. Well, neither does bathing - that's why we recommend it daily." -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
