Basic Memory Concepts
A bit has two values (on or off, 1 or 0)
A byte is a sequence of 8 bits.
Integer, and float type variables are stored in 4 bytes or 32 bits,
whil…e long, and double are stored in 8 bytes or 64 bits.
Memory is a one large array containing bytes as its elements.
In computer terminology, index for memory array is called an
address, which refers to a location in the memory array
Each address stores one element of the memory "array", which is
typically one byte. There are some memory configurations where each
address stores something besides a byte, but here we are dealing
with only bytes.
Big and Little - Endian formats:
Represents the order in which a sequence of bytes is stored in
Everything in Java binary format files is stored in big-endian
format, MSB (Most Significant Byte) first. This is referred to
as big-endian byte sex or sometimes network order.
For example, consider the number 1025 stored in a 4-byte
1025 in binary = 10000000001 (2 to the tenth power plus
The "leftmost" bit in a byte is the biggest. So, the binary
sequence 00000100 00000001 is the decimal number 1025.
00000100 00000001 = (210 + 20 = 1024 + 1 = 1025).
Bits in a byte are numbered from right-to-left, and bit 0 is the
rightmost and the smallest; bit 7 is leftmost and largest.
Thus (underlined) 1 (which is 2 to the power of 10 = 1024)
is the most significant digit, and the other 1 (which is 2 to the
power of 0 = 1) is the least significant digit.
In a little-endian system, the least significant byte
(LSB) in the sequence is stored first, therefore it is
stored exactly opposite of big-endian format as follows:
Big-Endian representation of 1025
Little-Endian representation of 1025
Big-endian: used by
Java virtual machine (JVM),
Little-endian: used by
Intel processors (CPUs) and DEC Alphas,
Windows on x86, x64
Many mainframe computers, particularly IBM mainframes, use
big-endian architecture. Most modern computers, including PCs, use
the little-endian system. (MORE)