Questions about this topic? Sign up to ask in the talk tab.

Difference between revisions of "Byte"

From NetSec
Jump to: navigation, search
 
(Expanded and made more exact)
Line 1: Line 1:
A byte represents 8 bits of data.  A bit of data is simply a 1 or 0.  Bytes are typically described by two [http://wiki.dotslashproductions.net/Assembly_Basics#Counting hexadecimal] characters.
+
A byte represents (most often) 8 (can be 10, 12, 15... depending on your architecture) bits of data.  A bit of data is simply a 1 or 0, that may represent an "off" or "on" state, or whatever the programmer decides.
  
Their values go 0-9 and A-F. A represents ten. So when you see FF:
+
== Representation ==
 +
8-bits bytes are typically described by two [http://wiki.dotslashproductions.net/Assembly_Basics#Counting hexadecimal] characters.
  
F is fifteen.  So you multiply 15 * 16 because it is in the 16's placeholder.
+
Hexadecimal is often notated with character ranges from 0 to 9 and then from A F. A represents "10", B 11, C 12, D 13, E 14, F 15.  
This gives you the value 240.  You add that to the second F (15) to get 255.
+
  
This is the highest value of a byte.  As such a byte can only hold integers 0-255, which is 256 values because it starts at zero.
+
== How to read an hexadecimal number, and a byte ==
  
= Reference =
+
{{quote|Just like decimal numbers, you epsilons!|Savitri}}
  
 +
Let's take a random byte: 11010011
 +
 +
In hexadecimal, it is: D3
 +
 +
Hexadecimal, means (that's greek) "radix 16", or more commonly "base 16".
 +
 +
So this means, reading from right to left, the first ranking number will be multipled by 16^0 (equals 1), second ranking number will be multipled by 16<sup>1</sup> (equals 16), third by 16<sup>2</sup>, n<sup>th</sup> by 16<sup>n+1</sup>...
 +
 +
* 3 in hexadecimal is 3 in decimal, too (how surprising!)
 +
* D in hexadecimal is 13 in decimal, too.
 +
 +
So to convert this number to base 10, we compute:
 +
 +
3 * 1 + 13 * 16 = 3 + 208 = 211
 +
 +
 +
= Reference =
 +
<pre>
 
   0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
 
   0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
 
   0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
 
   0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
 
+
</pre>
 
[[Category:Information]]
 
[[Category:Information]]

Revision as of 01:46, 16 November 2011

A byte represents (most often) 8 (can be 10, 12, 15... depending on your architecture) bits of data. A bit of data is simply a 1 or 0, that may represent an "off" or "on" state, or whatever the programmer decides.

Representation

8-bits bytes are typically described by two hexadecimal characters.

Hexadecimal is often notated with character ranges from 0 to 9 and then from A F. A represents "10", B 11, C 12, D 13, E 14, F 15.

How to read an hexadecimal number, and a byte

Savitri says
Just like decimal numbers, you epsilons!

Let's take a random byte: 11010011

In hexadecimal, it is: D3

Hexadecimal, means (that's greek) "radix 16", or more commonly "base 16".

So this means, reading from right to left, the first ranking number will be multipled by 16^0 (equals 1), second ranking number will be multipled by 161 (equals 16), third by 162, nth by 16n+1...

  • 3 in hexadecimal is 3 in decimal, too (how surprising!)
  • D in hexadecimal is 13 in decimal, too.

So to convert this number to base 10, we compute:

3 * 1 + 13 * 16 = 3 + 208 = 211


Reference

  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15