Computer Data Formats Industrial Informatics, Production and Logistics by Wolfgang Neff
Numeral Systems (1) Our numeral system uses 10 digits to represent all numbers. –0, 1, 2, 3, 4, 5, 6, 7, 8, 9 –base-ten numeral system The value of a digit depends on its position: positional numeral system The values of numbers have to be calculated. –2005 = 2∙ ∙ ∙10 + 5∙1 –MMV = (in contrast to above)
Numeral Systems (2) Generalisation –Base-b Numeral Systems. –Base: Number of digits –Value:
Decimal System (1) Base: 10 –base-ten numeral system Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Value of a decimal number –1001 = 1∙ ∙ ∙ ∙10 0 1∙ ∙ ∙10 + 1∙ dec
Decimal System (2) Representation of a decimal number –1001 =1001 ÷ 10= 100remainder ÷ 10= 10remainder 0 10 ÷ 10= 1remainder 0 1 ÷ 10= 0remainder dec Number range of a given number of digits –10 Number of digits –4 digits: 10 4 = 0 … 9999 ready reading direction
Binary System (1) Base: 2 –base-two numeral system Digits: 0, 1 Value of a binary number –1001 = 1∙ ∙ ∙ ∙2 0 1∙8 + 0∙4 + 0∙2 + 1∙1 9 dec
Binary System (2) Representation of a binary number –9 =9 ÷ 2= 4remainder 1 4 ÷ 2= 2remainder 0 2 ÷ 2= 1remainder 0 1 ÷ 2= 0remainder bin Number range of a fixed number of digits –2 Number of digits –4 digits: 2 4 = 16 0 … 15
Binary Numbers (1) Computers only understand two states. –Current is flowing / Current is not flowing –Switch on / Switch off These two states are denoted by –0 / 1 or H / L (H for high, L for low) All data has to be encoded by these two states. Computers use the base-two system.
Binary Numbers (2) A binary digit is called bit. Bits are grouped as a single bit contains only very little information : –4 bits: Nibble –8 bits: Byte –16 bits: Word –32 bits: Double Word
Binary Numbers (3) Bytes are used to measure storage media. To keep numbers handy binary prefixes (Kilo, Mega, Giga, Terra etc.) are used. Binary prefixes are powers of 1024 (2 10 ). –1 KByte (KB): = Bytes = 1024 Bytes –1 MByte (MB): 1024 KB = Bytes = 1,048,576 Bytes –1 GByte (GB): 1024 MB = Bytes = 1,073,741,824 Bytes –1 TBytte (TB): 1024 GB = Bytes = 1,099,511,627,776 Bytes
Binary Numbers (4) Binary Numbers are difficult to read. There- fore four of them are grouped and a new digit assigned to C D A1110E B1111F As sixteen digits are needed this code is a base-sixteen numeral system.
Binary Numbers (5) Examples –0000 0– 64 –0111 7– 7A –1010 A– BC –FFFF F– FF C D A1110E B1111F
Hexadecimal System (1) Base: 16 –hex numeral system –base-sixteen numeral system Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Value of a decimal number –1001 = 1∙ ∙ ∙ ∙16 0 1∙ ∙ ∙16 + 1∙ dec
Hexadecimal System (2) Representation of a hex number –4097 =4097 ÷ 16= 256remainder ÷ 16 = 16remainder 0 16 ÷ 16= 1remainder 0 1 ÷ 16 = 0remainder hex Number range of a fixed number of digits –16 Number of digits –4 digits: 16 4 = 0 … (0 … FFFF)
Rapid Conversion Bin → Dec Write 1 above the last digit. Proceed doubling until you reach the beginning. Add all numbers where the digit below has a value of 1. Example: bin = = 179 dez
Rapid Conversion Dec → Bin Proceed doubling 1 until the result is larger than the number you want convert. Try to subtract both numbers. If it is possible the digit is 1 otherwise it is 0. Example: dez = bin
Rapid Conversion Bin ↔ Hex Conversion between bin and hex is most easily done with aid of a hex table. Every nibble can be assigned a hex digit an vice versa. HexBinHexBinHexBinHexBin C D A1010E B1011F1111
Addition (1) Addition has got two particularities. –Carries– Leading Zeros 1 st Number nd Number0512 Carry1000 Result2457 Leading Zero
Addition (2) Carry We get a carry if the result of an addition can not be expressed by a single digit (e. g. 9+5=14). It is transferred to the next position. Leading Zero Leading zeros can proceed numbers without changing their value (e. g. 0025=25). That way numbers can be filled.
Addition (3) 1 st Bit nd Bit Carry Result dec bin Adding two bytes the following situa- tions are encountered.
Addition (4) Example of a binary addition 1 st Number nd Number Carry Result
Fixed Bit Length (1) Number of digits of a binary number. The least valuable bit (rightmost) is called LSB (Least Significant Bit). The most valuable bit (leftmost) is called MSB (Most Significant Bit) Bit Number MSB (2 7 =128) LSB (2 0 =1)
Fixed Bit Length (2) Fixed bit lengths limit the number of possible values of a binary number. –8 bits: 2 8 → –16 bits: 2 16 → ,536 –32 bits: 2 32 → 0...4,294,967,296 The number of possible values is call range.
Fixed Bit Length (3) If a binary number exceeds its range an overflow occurs. Bit C st Number nd Number Carry Result The overflowed bit is called carry bit and is often discarded.
Fixed Bit Length (4) As the overflow is discarded binary numbers restart at zero if their range is exceeded. (After comes again). The number line becomes a number circle!
Negative Numbers (1) By counting beyond zero negative numbers are achieved.
Negative Numbers (2) Usually binary numbers whose MSB is set are considered negative. I. e. the MSB tags negative numbers. Example –8 th bit unset: are positive –8 th bit set: are negative –128 … 255 → -128 … -1
Negative Numbers (3) Positive values are sacrificed to achieve negative numbers. Which numbers are negative depends on the bit length. –Usually:positive:0...2 n-1 -1 negative: n-1 n:bit length
Negative Numbers (4) To get the negative of a given number use its two's complement. –Negate all bits of the number (0→1, 1→0) –Add the number 1 Number Negated Number Carry Result
Floating Point Numbers (1) Floating point numbers are a subset of the rational numbers. Floating point numbers have a distinct data type. All numbers containing a decimal point are considered floating point. Numbers without a decimal point are considered integer.
Floating Point Numbers (2) Floating Point Numbers are represented as exponential numbers. 10 to the power … is abbreviated by E. Examples: 5,05.0 · E0 3, · E , · E6 0, · E-3
Floating Point Numbers (3) The part after E is called mantissa. The part before E is called exponent. Floating point numbers are stored as: 4 th Byte3 rd Byte2 nd Byte1 st Byte SEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM SExponentMantissa Sign
Characters (1) Characters are encoded by integer numbers. There are several encoding schemes –ASCII: 7 bit encoding scheme –extended ASCII: 8 bit encoding scheme ANSI (Windows-1252) ISO Latin1 (ISO ) –Unicode: 32 bit encoding scheme
ASCII Lower Hex Digit ABCDEF Higher Hex Digit 0 NUL SOH STXETXEOFENQACKBEL BSHTLFVTFFCRSOSI 1 DLEDC1DC2DC3DC4NAKSYNETBCAN EM SUBESC FSGSRSUS 2 !"#$%&'()*+,-./ :;<=>? 5PQRSTUVWXYZ[\]^_ 6`abcdefghijklmno 7pqrstuvwxyz{|}~ DEL American Standard Code for Information Interchange: 1968
Unicode (1) ASCII is very limited. Not adequate for internationalisation. The solution is Unicode. All characters ever used should be encoded. It uses a 32 bit encoding scheme. –Variants: UTF-8, UTF-16, UTF-32
Unicode (2) Unicode is or organised in groups. –Diacritics and Ligatures à, å, ä, æ –Non-Latin writing systems Arabic: العربية Cyrillic: Кириллица –Logographic writing system Chinese: 汉语 –Special purpose characters Mathematics: ·, ×, ÷, ≈, ±, ∫, ∞
Important Expressions (1) numbering system digit range decimal system binary system hexadecimal system bit length MSB / LSB Zahlensystem Ziffer Wertebereich Dezimalsystem Binärsystem Hexadezimalsystem Bitbreite MSB / LSB
Important Expressions (2) carry leading zero overflow two's Complement floating point number character encoding scheme internationalisation (i18n) Übertrag Führende Null Überlauf Zweikomplement Gleitkommazahl Zeichen Kodierungsschema Internationalisierung