# What does BE or LE mean in Buffer functions?

## Problem

I have a PHP class for reading Binary data that I'm converting to NodeJS or finding the equivalent of a couple functions in NodeJS. The functions I'm interested in this BinaryReader class are `ReadULong` and `ReadUShort`. I believe these mean read Unsigned Long integer (4 bytes) and Unsigned Short integer (2 bytes). As I'm trying to find the equivalent for these in NodeJS, I get confused on which function to use between these:

``````buf.readUInt16LE(offset, [noAssert])

``````

What would `LE` or `BE` stand for in this case?

The Buffer docs are located here but I was unable to find an explanation for those here.

Also I've found a constant on the PHP class that says `const DEFAULT_BYTE_ORDER = 'L';`. Is this `L` same as that `L` in `readUInt32LE`? Is this whole thing about Byte Orders?

So far I've read these articles:

• Good Source at cplusplus.com for looking up variable types.
• PHP bytewise tutorial and binary math
• How to read binary files byte by byte in Node.js question at stackoverflow

If I could be given a couple more references to read about binary reading that would be much appreciated!

Problem courtesy of: Logan

## Solution

BE and LE stand for big Endian and little endian. In big endian, the most significant byte is stored in the smallest address, and in little endian, the least significant byte is stored in the smallest address. That being said, endian does indicate the byte order. You can see the pattern in one of the examples in the documentation:

``````var buf = new Buffer(2);

buf[0] = 0x3;
buf[1] = 0x4;

// 0x0304
// 0x0403
``````
Solution courtesy of: hexacyanide

## Discussion

This post first appeared on Node.js Recipes, please read the originial post: here

# Share the post

What does BE or LE mean in Buffer functions?

×