Podcast
Questions and Answers
What is the primary reason given for why writing/reading in binary can be challenging?
What is the primary reason given for why writing/reading in binary can be challenging?
- Binary numbers are too small to represent large values.
- Binary requires complex mathematical operations.
- Writing and reading long strings of 1s and 0s can be cumbersome. (correct)
- Binary is only compatible with older computer systems.
In the octal number system, multiplying a number by 8 adds a 0 to the end of the number.
In the octal number system, multiplying a number by 8 adds a 0 to the end of the number.
True (A)
What base is the octal number system?
What base is the octal number system?
8
Decimal 8 is equivalent to ____ in octal.
Decimal 8 is equivalent to ____ in octal.
Match the following decimal numbers with their octal equivalents:
Match the following decimal numbers with their octal equivalents:
Which of the following binary representations corresponds to the octal number 5?
Which of the following binary representations corresponds to the octal number 5?
If a number in base 10 is $10^9$, how many zeros are in the representation of that number?
If a number in base 10 is $10^9$, how many zeros are in the representation of that number?
The number 2097152 * 2
equals 4194304
The number 2097152 * 2
equals 4194304
What is the octal representation of the decimal number 9?
What is the octal representation of the decimal number 9?
What is the primary reason bits are not accessed individually in computer memory?
What is the primary reason bits are not accessed individually in computer memory?
The size of a byte has remained constant at 8 bits throughout the history of computing.
The size of a byte has remained constant at 8 bits throughout the history of computing.
What unit of information is typically transferred between the CPU and main memory in one go?
What unit of information is typically transferred between the CPU and main memory in one go?
A page is typically 4KB or 8KB, and its size depends on the ______ and system.
A page is typically 4KB or 8KB, and its size depends on the ______ and system.
Match the data sizes with their typical sizes:
Match the data sizes with their typical sizes:
Considering a hypothetical computer architecture where a 'kilobyte' is defined as 1000 bytes instead of 1024 bytes, and a 'word' on this system is 64 bits. If a program needs to allocate a data structure that is exactly 3.5 'kilobytes' in size, how many full 'words' will be allocated to store this data structure? (Assume that memory is allocated in terms of full words only.)
Considering a hypothetical computer architecture where a 'kilobyte' is defined as 1000 bytes instead of 1024 bytes, and a 'word' on this system is 64 bits. If a program needs to allocate a data structure that is exactly 3.5 'kilobytes' in size, how many full 'words' will be allocated to store this data structure? (Assume that memory is allocated in terms of full words only.)
On a system where memory addresses are 48 bits wide, what is the theoretical maximum number of uniquely addressable bytes?
On a system where memory addresses are 48 bits wide, what is the theoretical maximum number of uniquely addressable bytes?
What is the primary difference between Big Endian and Little Endian byte ordering?
What is the primary difference between Big Endian and Little Endian byte ordering?
Byte ordering is solely a software-dependent attribute and is not influenced by the hardware.
Byte ordering is solely a software-dependent attribute and is not influenced by the hardware.
Why is it important to be aware of byte ordering when exchanging data between different computer architectures?
Why is it important to be aware of byte ordering when exchanging data between different computer architectures?
In C, strings are typically _______-terminated, meaning they end with a null character.
In C, strings are typically _______-terminated, meaning they end with a null character.
Given an integer value 0x12345678
, how would it be stored in memory in a Little Endian system?
Given an integer value 0x12345678
, how would it be stored in memory in a Little Endian system?
Why was octal used in early computer systems?
Why was octal used in early computer systems?
A byte requires exactly 3 octal digits to be fully represented since 8/3 = 2.66.
A byte requires exactly 3 octal digits to be fully represented since 8/3 = 2.66.
What base is hexadecimal?
What base is hexadecimal?
In hexadecimal, multiplying a number by 16 adds a ______ to the end.
In hexadecimal, multiplying a number by 16 adds a ______ to the end.
Match the following number systems with their number of bits per digit:
Match the following number systems with their number of bits per digit:
Why is base 256 not commonly used despite aligning perfectly with 8-bit bytes?
Why is base 256 not commonly used despite aligning perfectly with 8-bit bytes?
Which of the following is NOT a valid hexadecimal digit?
Which of the following is NOT a valid hexadecimal digit?
The largest octal value a byte can hold is 377.
The largest octal value a byte can hold is 377.
Convert the decimal value 20 to its hexadecimal equivalent.
Convert the decimal value 20 to its hexadecimal equivalent.
Insanely Difficult: If a hypothetical computer system used base-32 numbers, and represented digits 0-9 and A-V (A=10, B=11,... V=31), what would be the base-10 equivalent of the base-32 number '1V'?
Insanely Difficult: If a hypothetical computer system used base-32 numbers, and represented digits 0-9 and A-V (A=10, B=11,... V=31), what would be the base-10 equivalent of the base-32 number '1V'?
Which of the following is an advantage of using hexadecimal representation?
Which of the following is an advantage of using hexadecimal representation?
When converting from hexadecimal to decimal, you multiply each hex digit by decreasing powers of 16.
When converting from hexadecimal to decimal, you multiply each hex digit by decreasing powers of 16.
What prefix is commonly used to denote a hexadecimal number?
What prefix is commonly used to denote a hexadecimal number?
To convert a decimal value to hexadecimal, you repeatedly ______ the decimal value by 16.
To convert a decimal value to hexadecimal, you repeatedly ______ the decimal value by 16.
Match the steps to their corresponding actions in converting decimal 3000 to hexadecimal:
Match the steps to their corresponding actions in converting decimal 3000 to hexadecimal:
If int value = 0xcafec00l;
is stored in memory, and int *ptr = &value;
, what does ptr
point to?
If int value = 0xcafec00l;
is stored in memory, and int *ptr = &value;
, what does ptr
point to?
Byte ordering is crucial for string data to maintain correct textual representation.
Byte ordering is crucial for string data to maintain correct textual representation.
In memory addressing, what determines the address of a multi-byte piece of data?
In memory addressing, what determines the address of a multi-byte piece of data?
Given the hexadecimal number 0xFA, what is its decimal equivalent?
Given the hexadecimal number 0xFA, what is its decimal equivalent?
An int
variable is stored in memory starting at address 0x1000
. Assuming an int
occupies 4 bytes, the subsequent int
variable, if stored immediately after, would start at address __________.
An int
variable is stored in memory starting at address 0x1000
. Assuming an int
occupies 4 bytes, the subsequent int
variable, if stored immediately after, would start at address __________.
Flashcards
Bit
Bit
The basic unit of information in computing, storing either 0 or 1.
Byte
Byte
A package of bits; today, it's commonly 8 bits. Uniquely addressable in memory.
Word
Word
The unit of data a CPU accesses at once. Can be 8, 16, 32, 64, or 128 bits.
Paragraph
Paragraph
Signup and view all the flashcards
Page
Page
Signup and view all the flashcards
Page Size
Page Size
Signup and view all the flashcards
Memory Address
Memory Address
Signup and view all the flashcards
Octal
Octal
Signup and view all the flashcards
Octal 10
Octal 10
Signup and view all the flashcards
Octal Multiplication by 8
Octal Multiplication by 8
Signup and view all the flashcards
0 in Decimal, Octal, Binary
0 in Decimal, Octal, Binary
Signup and view all the flashcards
1 in Decimal, Octal, Binary
1 in Decimal, Octal, Binary
Signup and view all the flashcards
2 in Decimal, Octal, Binary
2 in Decimal, Octal, Binary
Signup and view all the flashcards
3 in Decimal, Octal, Binary
3 in Decimal, Octal, Binary
Signup and view all the flashcards
4 in Decimal, Octal, Binary
4 in Decimal, Octal, Binary
Signup and view all the flashcards
5 in Decimal, Octal, Binary
5 in Decimal, Octal, Binary
Signup and view all the flashcards
Byte Order (Endianness)
Byte Order (Endianness)
Signup and view all the flashcards
Big Endian
Big Endian
Signup and view all the flashcards
Little Endian
Little Endian
Signup and view all the flashcards
When Byte Ordering Matters
When Byte Ordering Matters
Signup and view all the flashcards
Strings in Memory
Strings in Memory
Signup and view all the flashcards
Octal in early computers
Octal in early computers
Signup and view all the flashcards
Hexadecimal (Hex)
Hexadecimal (Hex)
Signup and view all the flashcards
Hex digit and bits
Hex digit and bits
Signup and view all the flashcards
Hex multiplication by 16
Hex multiplication by 16
Signup and view all the flashcards
Binary
Binary
Signup and view all the flashcards
Base 4
Base 4
Signup and view all the flashcards
Octal inefficiency with bytes
Octal inefficiency with bytes
Signup and view all the flashcards
Hexadecimal
Hexadecimal
Signup and view all the flashcards
Decimal to Hex Conversion
Decimal to Hex Conversion
Signup and view all the flashcards
Hex to Decimal Conversion
Hex to Decimal Conversion
Signup and view all the flashcards
Hex Prefix
Hex Prefix
Signup and view all the flashcards
Addressing
Addressing
Signup and view all the flashcards
Addressing Order
Addressing Order
Signup and view all the flashcards
Data Address
Data Address
Signup and view all the flashcards
Byte Ordering
Byte Ordering
Signup and view all the flashcards
String Byte Order
String Byte Order
Signup and view all the flashcards
Study Notes
- The lecture addresses aspects of information storage with focus on bits, bytes, words and hexadecimal representation, and also addresses data addressing and byte ordering, strings and code representation, including bitwise and logical operations
Bits, Bytes, Words, Paragraphs, and Pages
- The bit is the smallest unit of information in computing, storing two values: 0 (no electric current) and 1 (electric current).
- Computer memory consists of elements that each store one bit.
- Bits are small, so they are accessed in packages: bytes, words, paragraphs, or pages.
- A byte is the smallest standard package of bits, often hardware-dependent, but is commonly 8 bits today but has ranged from 6-9 bits.
- Bytes are uniquely addressable in memory.
- A word is the unit of information accessed by a CPU, which depends on the CPU (8, 16, 32, 64, or 128 bits).
- A word is the amount of data transferred between the CPU and main memory in one go.
- A paragraph is typically 16 bytes (128 bits).
- A page is typically 4KB (4096 bytes) or 8KB (8192 bytes) and also hardware/system dependent.
- A page is the amount of data transferred between main memory and secondary storage (hard disk or SSD).
- Memory is a physical byte array with each element having a unique address in the range of 0 to n-1 where n is the size of the memory.
- Most programming languages can access information at the byte level, and programs can manipulate each byte in memory because each byte has a unique address in physical memory.
Hexadecimal Representation
- Bits, Bytes, Words and Paragraphs are powers of 2, so hexadecimal is useful
- Computations often involve dividing or multiplying by a power of 2
- Multiplying and dividing by two in binary is easy as you can add or remove a 0
- Octal (base 8) is another option
- Octal is a base 8 number system: Digital 8 is Octal 10
- An octal digit can be represented by 3 bits, and multiplying a number by 8 adds a 0 to the end
- In early computing, bytes were 6 or 9 bits long, bytes could be represented by two or three octal digit, which explains why early computer system used Octal
- Today the most common byte is 8 bits long, and a byte requires 3 Octal digits
- The common and most signifcant digit is not used
- We want something where # of bits per digit divides nicely into 8
- Other Options are
- Base 2 (Binary) with 1 bit per digit
- Base 4 with 2 bits per digit
- Base 16 with 4 bits per digit -Base 256 with 8 bits per digit
- Hexadecimal is base 16 number system that uses 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
- Multiplying a number by 16 adds a 0 to the end
- A hex Digit can be represented by 4 bits and every 4-bit number represent a single hexagon
- A byte is 8 bits and can be represented by 2 hex digits
- 216 (base 10) = D8 (base 16) = 11011000 (base 2)
- 1048576 (base 10) = 100000 (base 16)
- It's best to do everything in hex as it can avoid conversion mistakes given all arithmetic rules apply, and uses fewer digits
- To convert from decimal to hex: repeatedly divide the decimal value by 16, with the remainder being the digit in the hex representation
- To convert from hex to decimal: Multiply each hex digit by incresing power of 16 and add result
- Hex representations are typically prefixed with 0x, and should be internalized without conversions
Addressing and Byte Ordering
- Addressing refers to how data is located in memory, and is relatively standard
- Each byte has a unique address, in increasing order
- A piece of data in memory consists of 1 or more bytes
- The address of that piece of data is the address of the first byte of the data.
- Byte ordering refers to the order of bytes in a piece of data
- For data such as pieces of strings, the order of the bytes only depends on the data itself
- There are two forms of byte orders for numerical data types (integers and floats) and pointers:
- Big Endian: bytes are ordered from most significant to least significant
- Little Endian: bytes are ordered from least significant to most significant
- Byte ordering is hardware (CPU) dependent, and neither is better than the other
- Byte ordering matters when reading / writing binary data to files, when receiving / sending binary data over the network, for exchanging data between different computer architectures, and when debugging
- Debugging requires looking at raw data in memory, and knowing whether system is bit or little endian, and to use this kowledge to interpret values
Strings and Code in Memory
- Strings are stored as sequences of bytes in memory, and most use nul-terminated strings, of 0 or more bytes- none of which is nul (0)
- A string of n characters takes n+1 bytes to store as strings are terminated by a nul (0) chracter
- Each character is assumed to be ACSII which is 1 byte per character
- In Java, Unicode for string Encoding is used that is 2 bytes per character
- ASCII (American Standard Code for Information Interchange), all characters are one byte in size, originally of 7 bits are used
- ASCII encoding does not contain any non-english characters or special symbols Unicode can encode characters from most known languages, as UTF-16 uses 2 bytes per character, and UTF-8 is variable length encoding that is same as ASCII for first 128 characters.
- Each program instruction is a sequences of one or more bytes, and the CPU executes by moving a pointer in memory
Bitwise and Logical Operations
- We can't address a single bit as we cannot read or set one
- Must access the byte of word containing the bit to be set or read
- A byte us denoted by the char type in C, and a word is denoted by the int type
- Implement function which takes a byte and integer, and returns to value of the ith bit in that byte
- Bit 0 is the least significant bit, and bit 7 is the most significant bit
- The >> operator right shifts the desired bit to position 0, and the & operator computes the biswise AND of 000000001 and the result of right shift
- The result is the bit moved to positition 0
- List of Bitwise and Logical Operators
Further Problems to Solve
- Implement function that sets unsigned b with int i, returns byte b with ith bit set to 1
- Implement function to create a reset functing with same inputs, that returns with ith bit set to 0
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Explore number systems like binary and octal, their conversions, and challenges. Learn about memory organization, bytes, and data transfer units between the CPU and main memory like pages.