Edit Anything

Professional text and hex editing
with Binary Templates technology.






SweetScape Knowledgebase
KB1030: How does endianness work for templates?

Endianness refers to the byte order when reading data from a file. Binary data can either be stored in big-endian or little-endian mode (for more information on endian see 'Introduction to Byte Ordering' in the 010 Editor manual). For example, if a 'ushort' variable was read from the hex bytes 'FF 00', its value would be 256 in little-endian mode but 65280 in big-endian mode.

Every Template has a current endian setting and each variable that gets defined is set to that endian. By default, the current endian is the endian from the current file setting (you should see 'LIT' in the status bar if your file is in little-endian mode, or 'BIG' in the status bar if your file is in big-endian mode). This endian is set when a file is opened by the current 'File Interface' and can be changed using the 'View > Endian' menu or the shortcuts 'Ctrl+E', or 'Ctrl+Shift+E'.

It is possible to switch to a different endian setting using the 'BigEndian();' or 'LittleEndian();' functions. If your binary format is always defined in a particular endian, it is a good idea to call the appropriate endian function at the start of your template. All variables defined after a call to 'BigEndian();' or 'LittleEndian();' will use that endian setting. It is even possible to mix big and little-endian data in a single file. For example:

     BigEndian(); 
     int bigInt;
     LittleEndian();
     int littleInt;


Back to knowledgebase index
Back to main support page



Our Products


Latest News


Download
- 010 Editor
v7.0.2
is now available.

Download it now!
What's New in 7.0.2?


Newsletter
Join our newsletter to receive tips and tricks on hex editing, special offers, and news from SweetScape Software Inc.

Sign-up Now...