• Popular Now

• 14
• 12
• 9
• 10
• 13

Archived

This topic is now archived and is closed to further replies.

Endian Flip

This topic is 6081 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I''m attempting to grab a number from a big endian data stream like this:
  inline const unsigned int CLightwaveModel::GetU4(void) { //Advance the index m_DataIndex += sizeof(unsigned int); //Return the value return (((char)m_Data[m_DataIndex-4]<<24) +((char)m_Data[m_DataIndex-3]<<16) +((char)m_Data[m_DataIndex-2]<<8) +(char) m_Data[m_DataIndex-1]); } 
However I can''t seem to work out the exact syntax. I see the data like this: 00 00 01 90 A quick check in calc tells me this is 400 in decimal, which is the number I expected to get. When I run my code the above function returns 144. Can anyone see anything silly in my code? Many thanks Chris Brodie http:\\fourth.flipcode.com