1 / 17

Bits, Nybbles, Bytes, numbers and characters

Bits, Nybbles, Bytes, numbers and characters. Brian Mapes MPO581 Jan 24, 2011 from googling and poaching. Data Types. bit - a 0 or 1. Can represent 2 unique values byte - 8 bits. 256 values -128 to 128 unsigned byte - 8 bits 0 to 256 character – an alphabet-mapped byte

chelsi
Download Presentation

Bits, Nybbles, Bytes, numbers and characters

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Bits, Nybbles, Bytes, numbers and characters Brian Mapes MPO581 Jan 24, 2011 from googling and poaching

  2. Data Types • bit - a 0 or 1. Can represent 2 unique values • byte - 8 bits. 256 values -128 to 128 • unsigned byte - 8 bits 0 to 256 • character – an alphabet-mapped byte • short int - 16 bits -32767 to 32767 • long int – 32 bits 4,294,967,296 values • float - 32 bits coded: mantissa,exp • double - 64 bits coded • word – machine dependent. 32 or 64 bits

  3. Binary Equivalents of Decimal Numbers DecimalBinary (LR) Binary (R L) 0 0000 0000 1 0001 1000 2 0010 0100 3 0011 1100 4 0100 etc. 5 0101 6 0100 7 01118 1000 Is “most significant bit” (MSB) at “right” or “left”? (right and left are arbitraryin computer chip memory space)

  4. Powers of 2 DecimalDecimal 20 1 28 256 21 2 29 512 22 4 210 1024 23 8 211 2048 24 16 212 4096 25 32 213 8192 26 64 214 16384 27 128 215 32768

  5. Decimal (base 10) numbers • A decimal number can be represented as the sum of powers of 10 (the base) with coefficients in the base 10 alphabet (0 - 9) For example: 2485 = 2000 + 400 + 80 + 5 2485 = 2 * 1000 + 4 * 100 + 8 * 10 + 5 * 1 2485 = 2 * 103 + 4 * 102 + 8 * 101 + 5 * 100 Same principle can be applied in binary...

  6. Hexadecimal Numbers (nybbles or half-bytes) • 4 bits  Base-16 number system • Uses digits 0 - 9 and letters A - F • One hexadecimal digit can express values from 0 to 15 • For example: C represents 12 • (Not important for us - Used in memory addressing, sometimes wifi passwords,...)

  7. Hexadecimal - Binary Equivalents Hex Binary Hex Binary 0 0000 8 1000 1 0001 9 1001 2 0010 A 1010 3 0011 B 1011 4 0100 C 1100 5 0101 D 1101 6 0110 E 1110 7 0111 F 1111

  8. Characters and strings • Characters and Strings • EBCDIC, Extended Binary Coded Decimal Interchange Code • Used by IBM in mainframes (360 architecture and descendants). • Earliest system • ASCII, American Standard Code for Information Interchange. • Most common system • Unicode, http://www.unicode.org • New international standard • Variable length encoding scheme with either 8- or 16-bit minimum • “a unique number for every character, no matter what the platform, no matter what the program, no matter what the language.”

  9. The Unicode Character Set • Each character stored as 16-bits • Maximum number of characters that can be represented: 65,536 (216) • ASCII character set (used by many programming languages) stores each character as 7 bits (maximum number of characters is 128). • For compatibility, first 128 characters of Unicode set represent the ASCII characters

  10. Some Unicode Characters Unicode CharacterDecimal Value * 42 1 49 2 50 A 65 B 66 a 97 b 98 } 125

  11. Bytes as the “element” of data • Memory: Can be viewed as an array of storage elements. • The index of each element is called the address. • Each element holds the same number of bits. • How many bits per element? 8, 16, 32, 64? • 8 (Byte) is typical • Words are about the processor: how many bytes are loaded into a register and processed at once? • 32-bit word common, 64-bit  faster double math 8 bits = 1 byte 16 bits 32 bits 64 bits 0 0 0 0 1 1 1 1 2 2 2 2 ... ... ... ... n-1 n-1 n-1 n-1

  12. Single precision

  13. Charles Babbage 1791-1871Lucasian Professor of Mathematics, Cambridge University, 1827-1839 CS152-Spring’09

  14. The first programmer Ada Byron aka “Lady Lovelace” 1815-52 Ada’s tutor was Babbage himself! CS152-Spring’09

  15. Babbage’s Influence • Babbage’s ideas had great influence later primarily because of • Luigi Menabrea, who published notes of Babbage’s lectures in Italy • Lady Lovelace, who translated Menabrea’s notes in English and thoroughly expanded them. “... Analytic Engine weaves algebraic patterns....” • In the early twentieth century - the focus shifted to analog computers but • Harvard Mark I built in 1944 is very close in spirit to the Analytic Engine. CS152-Spring’09

  16. Application Programs High-Level Languages Machine independent High-Level Language Machine specific Low-Level Language Assembly Language Machine Language Hardware A Hierarchy of Languages

  17. Bit depths in color • 16 bits per pixel (high color) • 5 bits for red, 5/6 bits for green, 5 bits for blue • potential of 32 reds, 32/64 green, 32 blues • total colors: 65536 • 32 bits per pixel (true color) • 8 bits for red, green, blue, and alpha • potential for 256 reds, greens, and blues • total colors: 16777216 (more than the eye can distinguish)

More Related