Number Systems and Memory
41 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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.

True (A)

What base is the octal number system?

8

Decimal 8 is equivalent to ____ in octal.

<p>10</p> Signup and view all the answers

Match the following decimal numbers with their octal equivalents:

<p>0 = 0 1 = 1 2 = 2 3 = 3 4 = 4 5 = 5 6 = 6 7 = 7</p> Signup and view all the answers

Which of the following binary representations corresponds to the octal number 5?

<p><code>101</code> (D)</p> Signup and view all the answers

If a number in base 10 is $10^9$, how many zeros are in the representation of that number?

<p>9 (B)</p> Signup and view all the answers

The number 2097152 * 2 equals 4194304

<p>True (A)</p> Signup and view all the answers

What is the octal representation of the decimal number 9?

<p>11</p> Signup and view all the answers

What is the primary reason bits are not accessed individually in computer memory?

<p>Addressing individual bits would increase complexity. (C)</p> Signup and view all the answers

The size of a byte has remained constant at 8 bits throughout the history of computing.

<p>False (B)</p> Signup and view all the answers

What unit of information is typically transferred between the CPU and main memory in one go?

<p>word</p> Signup and view all the answers

A page is typically 4KB or 8KB, and its size depends on the ______ and system.

<p>hardware</p> Signup and view all the answers

Match the data sizes with their typical sizes:

<p>Byte = 8 bits Paragraph = 16 bytes (128 bits) Page = 4KB (4096 bytes) or 8KB (8192 bytes) Word = Varies (8, 16, 32, 64, or 128 bits)</p> Signup and view all the answers

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.)

<p>437 words (C)</p> Signup and view all the answers

On a system where memory addresses are 48 bits wide, what is the theoretical maximum number of uniquely addressable bytes?

<p>$2^{48}$ bytes (C)</p> Signup and view all the answers

What is the primary difference between Big Endian and Little Endian byte ordering?

<p>Big Endian stores bytes from most to least significant, while Little Endian stores them from least to most significant. (A)</p> Signup and view all the answers

Byte ordering is solely a software-dependent attribute and is not influenced by the hardware.

<p>False (B)</p> Signup and view all the answers

Why is it important to be aware of byte ordering when exchanging data between different computer architectures?

<p>Different architectures may use different byte orders, leading to misinterpretation of data if not handled correctly.</p> Signup and view all the answers

In C, strings are typically _______-terminated, meaning they end with a null character.

<p>nul</p> Signup and view all the answers

Given an integer value 0x12345678, how would it be stored in memory in a Little Endian system?

<p><code>78 56 34 12</code> (A)</p> Signup and view all the answers

Why was octal used in early computer systems?

<p>Early bytes were often 6 or 9 bits long, which could be represented by two or three octal digits. (B)</p> Signup and view all the answers

A byte requires exactly 3 octal digits to be fully represented since 8/3 = 2.66.

<p>False (B)</p> Signup and view all the answers

What base is hexadecimal?

<p>16</p> Signup and view all the answers

In hexadecimal, multiplying a number by 16 adds a ______ to the end.

<p>0</p> Signup and view all the answers

Match the following number systems with their number of bits per digit:

<p>Binary = 1 bit Base 4 = 2 bits Hexadecimal = 4 bits Base 256 = 8 bits</p> Signup and view all the answers

Why is base 256 not commonly used despite aligning perfectly with 8-bit bytes?

<p>It involves too many different digits, making it impractical. (C)</p> Signup and view all the answers

Which of the following is NOT a valid hexadecimal digit?

<p>G (D)</p> Signup and view all the answers

The largest octal value a byte can hold is 377.

<p>True (A)</p> Signup and view all the answers

Convert the decimal value 20 to its hexadecimal equivalent.

<p>14</p> Signup and view all the answers

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'?

<p>54 (C)</p> Signup and view all the answers

Which of the following is an advantage of using hexadecimal representation?

<p>Fewer digits are needed to represent large numbers. (C)</p> Signup and view all the answers

When converting from hexadecimal to decimal, you multiply each hex digit by decreasing powers of 16.

<p>False (B)</p> Signup and view all the answers

What prefix is commonly used to denote a hexadecimal number?

<p>0x</p> Signup and view all the answers

To convert a decimal value to hexadecimal, you repeatedly ______ the decimal value by 16.

<p>divide</p> Signup and view all the answers

Match the steps to their corresponding actions in converting decimal 3000 to hexadecimal:

<p>3000 / 16 = 187, remainder 8 = First Hex Digit (8) 187 / 16 = 11, remainder 11 = Second Hex Digit (B) 11 / 16 = 0, remainder 11 = Third Hex Digit (B)</p> Signup and view all the answers

If int value = 0xcafec00l; is stored in memory, and int *ptr = &value;, what does ptr point to?

<p>The address of the first byte of the integer value. (D)</p> Signup and view all the answers

Byte ordering is crucial for string data to maintain correct textual representation.

<p>True (A)</p> Signup and view all the answers

In memory addressing, what determines the address of a multi-byte piece of data?

<p>The address of the first byte.</p> Signup and view all the answers

Given the hexadecimal number 0xFA, what is its decimal equivalent?

<p>250 (C)</p> Signup and view all the answers

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 __________.

<p>0x1004</p> Signup and view all the answers

Flashcards

Bit

The basic unit of information in computing, storing either 0 or 1.

Byte

A package of bits; today, it's commonly 8 bits. Uniquely addressable in memory.

Word

The unit of data a CPU accesses at once. Can be 8, 16, 32, 64, or 128 bits.

Paragraph

Typically 16 bytes (128 bits) in size.

Signup and view all the flashcards

Page

Typically 4KB (4096 bytes) or 8KB (8192 bytes).

Signup and view all the flashcards

Page Size

The amount of information transferred between main memory and disk

Signup and view all the flashcards

Memory Address

A linear sequence of bytes, each with a unique location number.

Signup and view all the flashcards

Octal

A base-8 number system, using digits 0-7.

Signup and view all the flashcards

Octal 10

In octal, the number after 7 is 10 (eight).

Signup and view all the flashcards

Octal Multiplication by 8

Multiplying an octal number by 8 is equivalent to adding a 0 at the end.

Signup and view all the flashcards

0 in Decimal, Octal, Binary

0 in decimal, octal and binary

Signup and view all the flashcards

1 in Decimal, Octal, Binary

1 in decimal, octal and binary

Signup and view all the flashcards

2 in Decimal, Octal, Binary

2 in decimal, octal and binary

Signup and view all the flashcards

3 in Decimal, Octal, Binary

3 in decimal, octal and binary

Signup and view all the flashcards

4 in Decimal, Octal, Binary

4 in decimal, octal and binary

Signup and view all the flashcards

5 in Decimal, Octal, Binary

5 in decimal, octal and binary

Signup and view all the flashcards

Byte Order (Endianness)

The order in which bytes of a multi-byte number are stored in memory.

Signup and view all the flashcards

Big Endian

Bytes ordered from most significant to least significant.

Signup and view all the flashcards

Little Endian

Bytes ordered from least significant to most significant.

Signup and view all the flashcards

When Byte Ordering Matters

Reading/writing binary data to files, sending data over networks, exchanging data between architectures, and debugging.

Signup and view all the flashcards

Strings in Memory

A sequence of bytes in memory, often null-terminated in languages like C.

Signup and view all the flashcards

Octal in early computers

Early computer systems used octal because their bytes were often 6 or 9 bits long, which are easily represented by octal digits.

Signup and view all the flashcards

Hexadecimal (Hex)

Base-16 number system, uses 0-9 and A-F as digits.

Signup and view all the flashcards

Hex digit and bits

Each hexadecimal digit represents 4 bits.

Signup and view all the flashcards

Hex multiplication by 16

Multiplying by 16 in hexadecimal is like adding a 0 to the end of the number.

Signup and view all the flashcards

Binary

Base-2 number system using only 0 and 1.

Signup and view all the flashcards

Base 4

A number system with 4 as its base.

Signup and view all the flashcards

Octal inefficiency with bytes

Not fully utilized when representing a byte in octal, as a byte requires 3 octal digits, but the most significant digit isn't fully used.

Signup and view all the flashcards

Hexadecimal

A base-16 number system, uses 0-9 and A-F to represent values.

Signup and view all the flashcards

Decimal to Hex Conversion

Repeatedly divide the decimal by 16; remainders give hex digits in reverse order.

Signup and view all the flashcards

Hex to Decimal Conversion

Multiply each hex digit by increasing powers of 16, starting from 16^0, and add the results.

Signup and view all the flashcards

Hex Prefix

Prefix hexadecimal numbers with '0x' to distinguish them from decimal.

Signup and view all the flashcards

Addressing

The way data is located within computer memory; each byte has a unique address.

Signup and view all the flashcards

Addressing Order

Each byte has a unique identifier, which are sorted in ascending order.

Signup and view all the flashcards

Data Address

The location (address) of a multi-byte piece of data is the address of its first byte.

Signup and view all the flashcards

Byte Ordering

The order in which the individual bytes of a multi-byte data element are arranged in computer memory.

Signup and view all the flashcards

String Byte Order

For data like plain text strings, the order of bytes depends on the data itself.

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.

Quiz Team

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.

More Like This

Use Quizgecko on...
Browser
Browser