Lecture 5 Information Storage: Bits, Bytes and Addressing
42 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

Which of the following is the most basic unit of information in modern computing?

  • Bit
  • Byte
  • Paragraph (correct)
  • Word

Bytes are always 8 bits in size, regardless of the system architecture.

False (B)

What is the typical size, in bytes, of a 'page' in memory?

4096

A string of n characters, terminated by a null character, requires ______ bytes of storage.

<p>n+1</p> Signup and view all the answers

Match the following units of information with their typical sizes:

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

Which of the following is NOT a reason why hexadecimal is used?

<p>It aligns well with data sizes used in computer systems. (C)</p> Signup and view all the answers

In 'Big Endian' byte ordering, bytes are ordered from least significant to most significant.

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

What prefix is commonly used to denote a hexadecimal representation?

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

The American Standard Code for Information Interchange is more commonly known as ______.

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

Match the bitwise operator with its description:

<p>&amp; = Bitwise AND | = Bitwise OR ^ = Bitwise XOR ~ = Negate all bits</p> Signup and view all the answers

Why is it important to know the byte ordering (Endianness) when exchanging data between systems?

<p>To reduce network latency. (B)</p> Signup and view all the answers

ASCII can encode characters from all known languages.

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

How many hexadecimal digits are needed to represent a single byte?

<p>2</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 following number systems with their bases:

<p>Binary = Base 2 Octal = Base 8 Decimal = Base 10 Hexadecimal = Base 16</p> Signup and view all the answers

What is a 'word' in the context of computer architecture?

<p>A section of memory containing program code. (B)</p> Signup and view all the answers

Addresses of bytes in memory are always decreasing.

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

In C, what data type is typically used to represent a byte?

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

Each byte in physical memory has a unique ______.

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

Match the following values to their bitwise complement (using ~ operator):

<p>0x00 = 0xFF 0x55 = 0xAA 0xF0 = 0x0F 0xC3 = 0x3C</p> Signup and view all the answers

If x = 0xD5 (11010101 in binary) and y = 0x5D (01011101 in binary), what is the result of x & y (bitwise AND)?

<p>0x00 (00000000) (B)</p> Signup and view all the answers

A bitwise OR operation will always result in a value that is less than or equal to either of the operands.

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

What is the primary difference between ASCII and Unicode?

<p>encoding range</p> Signup and view all the answers

In the function int test(unsigned char b, int i) { return (b >> i) & 1; }, the >> operator performs a ______ shift.

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

Match the following operators with their function:

<blockquote> <blockquote> <p>= Right shift &lt;&lt; = Left shift &amp; = Bitwise AND | = Bitwise OR</p> </blockquote> </blockquote> Signup and view all the answers

In the context of strings, what does 'null-terminated' mean?

<p>The string contains only null characters. (C)</p> Signup and view all the answers

The size of a 'word' is consistent across all CPU architectures.

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

What is the purpose of prefixing a hexadecimal number with '0x'?

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

The process of accessing data in memory is commonly referred to as ______.

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

Match the following terms to their descriptions:

<p>Big Endian = Most significant byte first Little Endian = Least significant byte first ASCII = American Standard Code for Information Interchange Unicode = Encoding standard for characters</p> Signup and view all the answers

Which encoding uses a variable number of bytes to represent characters, and is backward compatible with ASCII for the first 128 characters?

<p>UTF-32 (D)</p> Signup and view all the answers

Bitwise operators are used for control flow decisions in most programming languages.

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

Explain the role of the null character in string representation within the C programming language.

<p>string terminator</p> Signup and view all the answers

The ______ operator in C performs a bitwise exclusive OR (XOR) operation.

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

Match the following hexadecimal values with their decimal equivalents:

<p>0x0A = 10 0x10 = 16 0xFF = 255 0x40 = 64</p> Signup and view all the answers

What determines whether a system uses Big Endian or Little Endian byte ordering?

<p>The operating system. (C)</p> Signup and view all the answers

0xAF & 0xF0 will always be equal to 0xAF

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

Explain why hexadecimal representation is preferred over decimal when discussing memory addresses or binary data.

<p>compactness and direct bit correspondence</p> Signup and view all the answers

If x = 5 and you perform a left bit shift operation x << 2, the new value of x will be ______.

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

Match the size to unit

<p>Bit = Base Unit Byte = 8 bits Paragraph = 16 bytes Page = 4/8kb</p> Signup and view all the answers

This question is incredibly challenging and requires abstract thinking. Consider a hypothetical computer architecture where each byte is composed of 7 bits instead of the conventional 8. If a programmer needs to store exactly 100 unique alphanumeric ASCII characters (which normally require 7 bits each to represent) and each character must take up a complete byte, how much memory, in these 7-bit bytes, will be needed to store these 100 characters?

<p><code>Insufficient information to determine</code> (A)</p> Signup and view all the answers

Imagine developing for a highly esoteric system where memory operations are extraordinarily expensive, and only bitwise operations are performant. You're tasked to create a function that efficiently checks if an unsigned integer n is a power of 4 (i.e., 4^0, 4^1, 4^2, ...). You can't use division, multiplication, or loops. The system uses 32 bit unsigned ints and must be implemented by using a one liner.

Given that powers of 4 have a single bit set at positions that are powers of two (e.g., 1, 4, 16, 64) -- meaning that when you subtract 1 from a power of 4, all bits below the set one will be set to 1, and powers of 4, when expressed in binary, have their '1' bit in an even position (0, 2, 4, 6, 8, etc.). To check this you do not want to just return the comparison operator. With n being a number to check. Which of the following fulfills the condition?

<p><code>n</code> is a power of 2. (B)</p> Signup and view all the answers

Flashcards

What is a bit?

The basic unit of information in modern computing that can store two different values: 0 or 1.

What is a byte?

A standard package of bits; today, it typically contains 8 bits and is the smallest addressable unit of memory.

What is word?

The unit of information accessed by a CPU; its size (number of bits) depends on the CPU architecture.

What is a paragraph?

A larger block of bytes, typically 16 bytes (128 bits) in size.

Signup and view all the flashcards

What is page?

A large, contiguous block of memory, typically 4KB (4096 bytes) or 8KB (8192 bytes), often used for memory management.

Signup and view all the flashcards

What is hexadecimal?

A numbering system with base 16, using digits 0-9 and letters A-F to represent values.

Signup and view all the flashcards

How programmers take bytes?

Most programming languages can access information at the byte level, as each byte has a unique address in physical memory.

Signup and view all the flashcards

What is addressing?

The location of data in computer memory, where each byte has a unique address in increasing order.

Signup and view all the flashcards

What is byte ordering?

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

Signup and view all the flashcards

What is Big Endian?

A byte order where bytes are arranged from the most significant to the least significant.

Signup and view all the flashcards

What is Little Endian?

A byte order where bytes are ordered from the least significant to the most significant.

Signup and view all the flashcards

How strings stored as?

Strings are stored as sequences of bytes in memory, often terminated by a null character.

Signup and view all the flashcards

What is ASCII?

A character encoding standard where each character is represented by a single byte.

Signup and view all the flashcards

What is Unicode?

A character encoding standard that can encode characters from most known languages.

Signup and view all the flashcards

What is Machine Code?

Each program instruction is encoded as a sequence of one or more bytes in memory.

Signup and view all the flashcards

What are Bitwise operators?

Operators that perform operations on individual bits within a byte or word.

Signup and view all the flashcards

What are Logical operators?

Operators that treat values as logically true or false and produce a Boolean result.

Signup and view all the flashcards

Bit is?

The fundamental unit of data is the bit.

Signup and view all the flashcards

Data Access and addressing?

Access and address data in packages.

Signup and view all the flashcards

Hexadecimal representation?

Hexadecimal aligns with sizes used in systems.

Signup and view all the flashcards

Byte is ordered?

Byte ordering depends on hardware.

Signup and view all the flashcards

String in memory?

Strings are encoded with ASCII or Unicode.

Signup and view all the flashcards

Bit manipulation done by?

Bit manipulation is done by manipulating values.

Signup and view all the flashcards

Study Notes

Information Storage

  • Assignment 0 is due on January 26
  • Lab 2 is this week

Lecture Contents

  • Bits, Bytes, Words, Paragraphs, and Pages will be covered
  • Hexadecimal Representation will be covered
  • Addressing and Byte Ordering will be covered
  • Representing Strings and Code will be covered
  • Bitwise and Logical Operations will be covered

Bits

  • The bit is the basic unit of information in modern computing
  • A bit can store two different values: 0 (no electric current) and 1 (electric current)
  • A computer's memory is a collection of elements that store one bit of information each
  • Bits are too small to be useful on their own
  • Addressing individual bits in memory is complex
  • Bits are accessed in packages (bytes, words, paragraphs, or pages)

Data Sizes

  • A byte is the "standard" smallest package of bits
  • Today, a byte contains 8 bits.
  • Bytes were 6-9 bits long
  • Bytes are uniquely addressable
  • A word is the unit of information access by a CPU
  • Words can be 8, 16, 32, 64, or 128 bits, depending on the CPU
  • A word is the amount of information 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)
  • Page size depends on hardware and the system
  • A page is the amount of information transferred between main memory and secondary storage

Memory

  • Memory is a physical byte array, where each element has a unique address
  • Addresses range from 0 to n-1, where n is the size of the memory

Programmers

  • Most programming languages access information at the byte level, at the same level that is addressable in memory
  • Since each byte has a unique address, programs can access and manipulate each byte

Hexadecimal Notation

  • Bits, bytes, words, and paragraphs are all powers of 2
  • Computations often multiplying and dividing by 2
  • Multiplying and dividing by 2 in binary is easy (add or remove a 0)
  • Writing and reading in binary is difficult
  • Octal (base 8) is an altenative

Octal

  • Octal is a base-8 number system
  • Decimal 8 is Octal 10
  • Multiplying a number by 8 adds a 0 to the end
  • Every 3-bit number is represented by a single octal digit
  • Early bytes were 6 or 9 bits long, so a byte was represented by two or three octal digits, and octal was used in early computer systems
  • Today a byte is 8 bits long
  • A byte requires 3 octal digits (8/3 = 2.66) to be represented
  • Idea: Have the number of bits per digit divides nicely into 8

Hexadecimal

  • Idea: Have # of bits per digit divides nicely into 8
  • Hexadecimal Number System has 16 digits: 0-9, A-F
  • Each digit in hexadecimal can be presented with only 4 bits
  • Base 16 multiplies numbers by 16, and then adds a zero at the end
  • Avoids conversion mistakes
  • Arithmetic rules apply
  • Fewer digits
  • Multiplying a number by 16 adds a 0 to the end
  • Prefix hex representations with 0x

Addressing

  • Addressing describes how data is located in memory
  • Addressing is relatively standard
  • Each byte has a unique address, in increasing order
  • Data in memory will uses one or more bytes
  • The address of a piece of data is the address of the first byte

Byte Ordering

  • Byte ordering is the order of bytes in a piece of data. String byte order depends on the data
  • There are two common byte orders for numerical data types, such as Integers (short, int, long), Floats (float, double), Pointers
  • Big Endian: bytes are ordered from most significant to least significant
  • Little Endian: bytes are ordered from least significant to most significant

Big Endian vs Little Endian

  • Byte ordering depends on the CPU
  • No order is intrinsically better than the other

Scenarios

  • When reading/writing binary data to files
  • When receiving/sending binary data over a network
  • When exchanging data between different computer architectures
  • When debugging and looking at the raw data in memory

Strings

  • Strings are stored as a sequence of bytes in memory
  • Languages usually use null-terminated string
  • A string may consist of 0 or more bytes, none of which is nul (0).
  • The string is terminated by a nul (0) character
  • A string of n characters takes n+1 bytes to store
  • ASCII: American Standard Code for Information Interchange
  • Simple, all characters are one byte in size, originally only 7 of 8 bits are used
  • Cannot encode non-English characters
  • Cannot encode special symbols beyond the standard ones. ` Unicode can encode characters from most known languages UTF-16 uses 2 bytes per character (for most characters) UTF-8 is a variable-length encoding that is the same as ASCII for the first 128 characters. It will assume that all character is ASCII encoding

Key Points

  • The fundamental unit of data is the bit, but data is addressed in packages of bytes, words, paragraphs, etc
  • Hexadecimal representation aligns with data sizes in the modern computer systems & should be used instead of decimal
  • When exchanging binary data between systems, byte ordering is critical because it is hardware-dependent
  • Strings are typically stored a nul-terminated sequence of bytes using ASCII or Unicode encoding
  • Bit manipulation involves manipulating data values containing the bits

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Description

Lecture covers bits, bytes, words and hexadecimal representation. Addressing and byte ordering along with representing strings and code will be discussed. Topics include the bit as the basic unit of information and data sizes.

More Like This

Introducción a Bits y Bytes
5 questions

Introducción a Bits y Bytes

PolishedComprehension7871 avatar
PolishedComprehension7871
Introduction to Bits and Bytes
42 questions
Use Quizgecko on...
Browser
Browser