Binary data is 0 or 1, false or true.
With this, you can use the logical operators: and, or, xor, not.
You can also convert binary data to hexadecimal notation: 1 hexadecimal sign is 4 bit (also called a “nibble”), this can go from 0 to F.
Two nibbles make a byte, 210 bytes is 1 kibibyte (KiB), 220 is a mebibyte (MiB), 230 is a gibibyte (GiB) and 240 is a tebibyte (TiB). These names were created to contrast the more popular kilobyte, megabyte, gigabyte, etc as they are more exact.
Natural numbers can easily be converted into binary and back.
156 = 10011100
10011100 = 156
Integers can also be converted, but here the possibility of a negative number needs to be taken into consideration. There are several ways to do this:
- Sign (+/-) and size:
This is limited to -7 – 7 in 4 bit or -127 – 127 in 8 bit
- 1s complement is simple inversion, this is also limited in size and by the negative 0:
5 = 0101
-5 = 1010
- 2s complement inverts and adds 1. It is also limited in size, but the lack of negative 0 has led to its more widespread use:
5 = 0101
-5 = 1011
Real numbers (floating points, in programming) can be converted, though it is more complex. This is done through the use of a sign (S)\exponent (the size)\significand (value). There are two ways of doing so:
- 1 \ 8 \ 23 (32 bit: a float)
- 1 \ 11 \ 52 (64 bit: a double, this is a larger and therefore more precise real number).
In programming, it is necessary to be careful with floats and doubles as the limitations of bits lead to rounding numbers and this can lead to complications when comparing two real numbers. The programmer must therefore allow for a margin of error.
The computer recognises bits as integers or real numbers by the assignment of types to variables.
Letters are represented by various systems: ASCII, EBCDIC, UCS-4, UNICODE
Unicode is the most used standard, it is always evolving and was created as a solution for the limitations of ASCII