Lecture 1 Number Representation and Bit Models
45 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 symbols are used by modern computers?

  • A, B, C, D, E, F
  • 0 and 1
  • 0, 1, and 2 (correct)
  • Any natural number

A group of 6 contiguous bits is called a byte.

False (B)

What is a single '0' or '1' called in the context of computers?

bit

A group of 8 contiguous bits, treated as a unit, is called a ______.

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

What is the 'bit model' used to represent strictly non-negative integers?

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

A 'nybble' is a group of 8 bits.

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

What is the name of the system used to write numbers where the position of a digit determines its value?

<p>positional representation</p> Signup and view all the answers

In the expression $3 \times 10^2 + 5 \times 10^1 + 7 \times 10^0$, the base is ______.

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

What is the decimal equivalent of the unsigned binary number 101010â‚‚?

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

When converting decimal to binary using the algorithm described, you read the 'bit' column from top to bottom.

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

During the conversion of decimal to binary, what value is assigned to 'bit' if the 'value' is even?

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

During decimal to binary conversion, the 'bit' is assigned a value of 1 if the 'value' is ______.

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

What is the binary representation of the decimal number 123?

<p>1011101â‚‚ (B)</p> Signup and view all the answers

Hexadecimal representation uses base 8.

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

What prefix is used to identify hexadecimal values?

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

In hexadecimal representation, the symbol 'A' represents the decimal value ______.

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

How many bits are needed to represent all possible values between 0 and 15?

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

When converting binary to hexadecimal, you should start grouping bits from the MSB (left end).

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

When converting binary to hexadecimal, what size should the groups of bits be?

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

If the number of bits is not a multiple of 4, ______ with zeros is necessary when converting binary to hexadecimal.

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

What is the hexadecimal representation of the binary number 1011 1010 1101?

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

A 64-bit word limits the virtual address space to 4GB.

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

What is the nominal size of pointer data related to in the context of computer memory?

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

Every computer has a ______ size, which is the largest number of contiguous bits the ALU handles.

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

Which of the following data types typically occupies 2 bytes of memory?

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

The C standard guarantees that all data types have fixed sizes across all implementations.

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

According to the C standard, what does the ISO C99 define to avoid vagaries of typical sizes?

<p>int32_t, int64_t</p> Signup and view all the answers

According to the content, all pointers are ______ bytes on 32-bit systems.

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

What format specifier in printf() is used for hexadecimal output?

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

In C, the printf() function is defined as part of the C language itself.

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

What does the %2d format specifier in printf() indicate?

<p>integer at least 2 digits wide</p> Signup and view all the answers

The format specifier ______ is used for a single character in C's printf() function.

<p>%c</p> Signup and view all the answers

According to the slide, what is specified by addresses?

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

In a big-endian system, the least significant byte is stored at the lowest memory address.

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

If variable x has a 4-byte value of 0x01234567 and its address is given by &x is 0x100, how is it stored in little endian?

<p>67 45 23 01</p> Signup and view all the answers

In a big-endian system, the most significant byte of a multi-byte value is stored at the ______ memory address.

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

Match the following hexadecimal values with their decimal equivalents:

<p>0x0 = 0 0xA = 10 0xF = 15 0x10 = 16</p> Signup and view all the answers

What is the result of the operation 0x503c + 0x40 (without converting to decimal)?

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

What is the range of values (in decimal) that can be represented by a single unsigned byte when written in hexadecimal?

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

Given $n = 19$, which of the following represents $2^n$ in hexadecimal?

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

Compilers are guaranteed by the C standard to treat char as signed.

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

What is the decimal value of the largest unsigned integer that can be represented with 3 bits?

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

In the context of memory addresses, successive word addresses differ by 8 bytes for ______-bit systems.

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

Assume that the address of a variable 'x', denoted as &x, is 0x100. Variable 'x' has the 4-byte value 0x0A0B0C0D. If the system uses little endian representation, what is the value of the byte at memory address 0x102?

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

If a value is displayed as 0x80, what is the decimal value if it is treated as a signed 8-bit integer?

<p>-128</p> Signup and view all the answers

Flashcards

Bit

A single '0' or '1' in computing.

Byte

A group of 8 contiguous bits, treated as a unit.

Nybble

A group of 4 bits.

Bit Model

A method of interpreting bits.

Signup and view all the flashcards

Unsigned Binary

A bit model representing non-negative integers.

Signup and view all the flashcards

Positional Representation

System for representing numbers based on position.

Signup and view all the flashcards

Radix (Base)

A number's base in positional notation.

Signup and view all the flashcards

Hexadecimal

Base-16 number system.

Signup and view all the flashcards

Binary to Hex Conversion

Converting binary to hexadecimal involves grouping bits into sets of four, starting from the right.

Signup and view all the flashcards

Word Size

Largest number of contiguous bits a computer's ALU can handle.

Signup and view all the flashcards

Size of Pointer Data

The nominal size of pointer data, indicating bits for a virtual address.

Signup and view all the flashcards

C Standard Minimum Sizes

guarantees minimum sizes. Actual size is implementation dependant.

Signup and view all the flashcards

Printf() Function

Converts numbers and prints them.

Signup and view all the flashcards

Byte Addressing

A view, addresses specify byte locations, indicating the first byte in a given word.

Signup and view all the flashcards

Big Endian

A byte ordering in which the most significant byte comes first.

Signup and view all the flashcards

Little Endian

A byte ordering in which the least significant byte comes first.

Signup and view all the flashcards

Study Notes

  • Modern computer hardware is based on binary digits, namely 0 and 1.
  • Computer stores everything as numbers.
  • The single symbols modern computers use are 0 and 1.
  • A single 0 or 1 is a bit, which means binary digit.
  • A group of 8 contiguous bits, treated as a unit is a Byte.
  • A group of 4 bits is a Nybble.
  • Bits are grouped, and methods are used for interpretation.
  • Each method of interpretation is a bit model.
  • The bit model for non-negative integers is unsigned binary.
  • Examining the bit-models of C data types provides insight into memory usage.
  • Numbers are written using a positional representation system.
  • The decimal number 357 is represented as 3 x 10^2 + 5 x 10^1 + 7 x 10^0.

Numbers in Base r

  • A number (dn-1dn-2...d1d0)r in base (or radix) r is expressed as dn-1 * r^(n-1) + dn-2 * r^(n-2) + ... + d1 * r^1 + d0 * r^0.
  • (bn-1bn-2...b1b0)2 in base 2 or binary is expressed as bn-1 * 2^(n-1) + bn-2 * 2^(n-2) + ... + b1 * 2^1 + b0 * 2^0
  • The unsigned binary number 1010102 equals 1 * 2^5 + 0 * 2^4 + 1 * 2^3 + 0 * 2^2 + 1 * 2^1 + 0 * 2^0 which is equal to 4210.

Conversion from Decimal to Binary

  • Start with two columns: value and bit
  • If the value is even, put a 0 in the bit column, and if odd, put a 1 in the bit column.
  • Update the value column, by setting the new value to the old value divided by 2 and rounded down.
  • The binary representation of the given value is the bit column read from bottom (MSB) to top (LSB).
  • Given 123 represented as 12310, the bit column bottom->top gives 11110112
  • Decimal numbers can be related to their bit patterns in binary.

Hexadecimal Representation

  • Modern computers use 32 or 64-bit words and to overcome this, base 16 is used.
  • Base 16 is hexadecimal (HEX) representation.
  • Hexadecimal needs 16 symbols, identified as "higits" from 0 to 15.
  • In HEX, symbols 0-9 are the same as in decimal.
  • After that: 10 is A, 11 is B, 12 is C, 13 is D, 14 is E, and 15 is F.
  • HEX values are identified with the prefix 0x, e.g., 0xF00D.

Converting Binary to Hex

  • Group bits into sets of 4 starting from the right end (LSB).
  • Pad the front with zeroes if necessary.
  • Replace each group of 4 with the "higit".

Converting Hex to Binary

  • Replace each "higit" with the group of 4 bits from the table.

Basic C Data Types

  • Every computer as a word size.
  • This is the largest number of contiguous bits that the ALU handles.
  • It manifests as the nominal size of pointer data i.e. the number of bits required for a virtual address.
  • A 32-bit word limits virtual address space to 4GB, while a 64-bit word allows 16 Exabytes.
  • Given the signed data types [signed] char, short, int, long, int32_t, int64_t, char *, float and double
  • The corresponding unsigned data types are unsigned char, unsigned short, unsigned int, unsigned long, unit_32, unit_64
  • And respective byte allocations 1, 2, 4, 4/8, 4, 8, 8, 4, 8.
  • Allocated sizes may vary but are typically as shown in the table.
  • ISO C99 defines int32_t and int64_t which are guaranteed 4 & 8 bytes, respectively.
  • C standard only guarantees minimum sizes and the actutal size is implementation dependant.
  • intN_t is guaranteed for N = 8, 16, 32, 64.
  • All pointers are 8 bytes (4 bytes for 32 bit systems).
  • Compilers typically treat char as signed, though it is not guaranteed in the C standard unless the prefix signed is used.
  • The C standard only guarantees lower bounds, except for intN_t types.
  • Printf() is a general purpose output formatting function.
  • Printf is not defined in C, and is part of the standard library of functions (stdio.h)
  • The first argument is a string of chars to be printed, with each % indicating a substituted argument.
  • For instance: printf("%2d\t%f\t%4.2f", dayNum, temperature, cost) DayNum is an integer at least 2 digits wide (%2d). Temperature is a floating point. Cost will print as floating point, at least 4 characters wide, 2 after the decimal point.
  • Other format specifiers: u unsigned, x/X (int) hex, c single char, f/g/G floating point, p pointer (void *).

Multi-Byte Data and Addressing

  • Programs use addresses to refer to data.
  • Data is conceptually in a large array of bytes.
  • An address is like an index into that array, and the pointer variable stores an address.
  • Systems give each process private address spaces.
  • Addresses specify byte locations, as such the address is of the first byte in the word.
  • Successive word addresses differ by 8 bytes (for 64-bit) and

Endianness

  • A variable x has a 4-byte value 0x01234567, and the address given by &x is 0x100.
  • In big endian, the bytes are stored in memory as 01 23 45 67.
  • In little endian, the bytes are stored in memory as 67 45 23 01.

Studying That Suits You

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

Quiz Team

Related Documents

Description

Explanation of binary digits, bits, bytes, and nybbles in computer hardware. Discussion of bit models, positional representation systems, and base r numbers, with examples of decimal and binary representations.

More Like This

The Binary World
8 questions

The Binary World

CourtlySalamander avatar
CourtlySalamander
Computer Memory and Binary Digits Quiz
10 questions
Use Quizgecko on...
Browser
Browser