byte

From SEGGER Wiki
Revision as of 02:38, 8 July 2019 by Rolf (talk | contribs)
Jump to: navigation, search

A byte consists of 8-bits. A byte is in many systems the basic unit of data that can be accessed or transferred. In some literature a byte is called Octet. Consisting of 8 bits, a byte can represent 2⁸ = 256 different values, ranging from 0 ... 255. The value of a byte can be conveniently shown in hex, with values ranging from 0 ... FF.

Unit symbol

The unit symbol for byte is uppercase letter B, in contrast to the unit symbol for bit, which is lowercase b.

Unit multiples

2^10 = 1024 is very close to 1000. In computers, multiples of powers of 2 are "natural" values, so used a lot.

Decimal multiples

As in physics, the standard SI (or metric) prefixes k, M, G are used to indicate 10^3, 10^6 and 10^9, so

1kB = 1000 Bytes
1MB = 1000'000 Bytes
1GB = 1000'000'000 Bytes
1TB = 1000'000'000 Bytes

Disk manufacturers tend to use the decimal multiples, which yield slightly bigger numbers than the binary multiples.

Binary multiples

The difference between the binary multiples and the decimal equivalents is not very big (2.4%) for k, but it goes up for the larger ones. Unfortunately, despite standardization efforts there is no clear standard for the binary prefixes. The following are used most commonly, leaving room for interpretation for M and G:

1KB = 1024 Bytes
1MB = 1024^2 = 1'048'576 Bytes
1GB = 1024^3 = 1'073'741'824 Bytes

A way to eliminate all confusion (that stems from the ambiguous M and G) is to use the dedicated binary prefixes:

1KiB = 1024 Bytes
1MiB = 1024^2 = 1'048'576 Bytes
1GiB = 1024^3 = 1'073'741'824 Bytes

More information

https://en.wikipedia.org/wiki/Binary_prefix
https://en.wikipedia.org/wiki/International_System_of_Units