CSE 30 Week 1

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What will the following output? int main() { int ex = -100; printf("%d %u\n", example, example); }

-100 4294967196 signed (%d) vs unsigned (%u)

What is the smallest possible signed char?

-128

What are the maximum and minimum values for 4-bit two's complement?

-8, 7

What is the smallest possible unsigned char?

0

Which logical value means false, 0 or 1?

0

0 1 1 1 -1 1 0 1

0 1 1 1 + 0 0 1 1 1 0 1 0

0 1 1 1 - 0 0 1 1

0 1 1 1 + 1 1 0 1 0b10100 <- extra one gets truncated to give the expected result -> 0b0100

What is the range for a 4-bit unsigned sequence?

0 to 15 (-8 to 7 for signed)

What symbols are used for binary numbers?

0-1

How many unique sequences are provided by 8 bits?

0-255

What symbols are used for octal numbers?

0-7

What symbols are used for decimal numbers?

0-9

What symbols are used for hexadecimal numbers?

0-9, A-F or a-f

What is the prefix for binary?

0b

Convert 0xB491 to binary.

0b 1011 0100 1001 0001

Negate 0b 0000 1101

0b 1111 0011

Convert the following two's complement number to decimal: 0b1101

0b0011 = -3

Convert 0x4 to binary.

0b0100

Convert 0x9 to binary.

0b1001

1 1 0 0 + 0 1 1 1

0b10011 <- doesn't fit in 4-bit, carry out 1 is truncated -> 0b0011 (overflow)

Convert 0xB to binary.

0b1011

Convert 0xF to binary.

0b1111

What is the prefix for hexadecimal?

0x

Convert 16 to hexadecimal.

0x10

Convert 17 to hexadecimal.

0x11

Convert 0xD to binary.

0x1101

Convert 18 to hexadecimal.

0x12

Convert 19 to hexadecimal.

0x13

Convert 20 to hexadecimal.

0x14

Convert the following from binary to hex: 0b1000111100

0x23C

Convert 0b0011 to hexadecimal.

0x3

Convert 0b 0011 1101 1001 to hexadecimal.

0x3D9

What is the hexadecimal representation of 0b 0100 1010?

0x4A

Convert 0b0110 to hexadecimal.

0x6

Convert 0b0111 to hexadecimal.

0x7

Convert 0b1010 to hexadecimal.

0xA

Convert 10 to hexadecimal.

0xA

Convert 11 to hexadecimal.

0xB

Convert 0b1100 to hexadecimal.

0xC

Convert 12 to hexadecimal.

0xC

Convert 13 to hexadecimal.

0xD

Convert 0b1110 to hexadecimal.

0xE

Convert 14 to hexadecimal.

0xE

Convert 15 to hexadecimal.

0xF

In a float, floating-point number, how many bits are dedicated to the sign?

1

Which logical value means true, 0 or 1?

1

What are the powers of 16 from 0 to 4?

1 16 256 4096 65536

Divide the following unsigned binary numbers: 0011)1100

1 0 0 0 0 1 1) 1 1 0 0 1 1 0 0 0 0

Multiply the following unsigned binary numbers: 1 0 1 * 0 1 1

1 0 1 * 0 1 1 1 0 1 1 0 1 0 0 0 0 1 1 1 1

Subtract the following unsigned binary numbers: 1 1 1 0 - 1 0 1 1

1 1 1 0 + 10 1 1 0 0 1 1

Add the following unsigned binary numbers: 1 1 1 0 + 1 0 1 1

1 1 1 0 + 10 1 1 1 1 0 0 1

List the powers of 2 from 0 to 8.

1, 2, 4, 8, 16, 32, 64, 128, 256

What is the base for a decimal number?

10

What is the base for decimals?

10

Divide 0b1010 by 2.

101 - shift right

Multiply 0b1010 by 2.

10100 - shift left

Add the following two's complement numbers: 0110 +1110

10100 -> 0100

Add the following two's complement numbers: 1000 + 1100

10100 <- overflow (negatives became a positive)

0 0 10 + 1 0 1 1

1101

Add the following two's complement numbers: 0111 +0110

1101 <- overflow (positives became a negative)

What is the largest possible signed char?

127

In a float, floating-point number, what is the bias?

127 (subtract from the exponent)

Convert the following fixed-point number to decimal: 0b1101.101

13.625

What is the base for a hexadecimal number?

16

What is the base for hexadecimal numbers?

16

How many bits is allocated for a short?

16 bits

What is the base for a binary number system?

2

What is the base for a binary number?

2

Express 28 as a polynomial in base 10.

2*10^1 + 8*10^0

What is the decimal representation of 0b 0100 1010?

2+8+64=74

In a float, floating-point number, how many bits are dedicated to the mantissa/significand?

23 bits

What is the largest possible unsigned char?

255

How many bits are in a float in C?

32 bits

How many bits is allocated for an int?

32 bits

How many bits is in an int?

32 bits

Convert the following fixed-point number to decimal: 0b100101.11

37.75

What is the binary representation of 389 (solve by powers method)?

389 -> 256 = 1 133 -> 128 = 1 5 -> 64 = 0 5 -> 32 = 0 5 -> 16 = 0 5 -> 8 = 0 5 -> 4 = 1 1 -> 2 = 0 1 -> 1 = 1 0b110000101

What is the hexadecimal representation of 389 (use the powers method)?

389->256 = 1 133->16 = 8 5->1 = 5 0x185

What is the hexadecimal representation of 389 (use the remainders method)?

389/16 -> R5 24/16 -> R8 1/2 -> R1 remainder -> backwards 0x185

What is the binary representation of 389 (solve by remainders method)?

389/2 -> R1 194/2 -> R0 97/2 -> R1 48/2 -> R0 24/2 -> R0 12/2 -> R0 6/2 -> R0 3/2 -> R1 1/2 -> R1 remainder -> backwards 0b110000101

How would you go about converting 422 to binary (using the powers method)?

422 -> 256 = 1 166 -> 128 = 1 38 -> 64 = 0 38 -> 32 = 1 6 -> 16 = 0 6 -> 8 = 0 6 -> 4 = 1 2 -> 2 = 1 0 -> 1 = 0 0b110100110

How would you go about converting 422 to binary (using the remainders method)?

422/2 -> R0 211/2 -> R1 105/2 -> R1 52/2 -> R0 26/2 -> R0 13/2 -> R1 6/2 -> R0 3/2 -> R1 1/2 -> R1 remainder -> backwards 0b110100110

Convert the following fixed-point number to decimal: 0b0101.001

5.125

Convert the following fixed-point number to decimal: 0b000101.10

5.5

In a float, floating-point number, how many bits are dedicated to the exponent?

8

What is the base for an octal number?

8

How would you convert 9742 to hexadecimal (using the powers method)?

9742 -> 65536 = 0 9742 -> 4096 = 2 1550 -> 256 = 6 14 -> 16 = 0 14 -> 1 = 14 (E)

How would you convert 9742 to hexadecimal (using the remainders method)?

9742/16 -> R14 (E) 608/16 -> R0 38/16 -> R6 2/16 -> R2 remainder -> backward 260E

How many bits do you need to store 2^N things?

N bits

How would you convert from base B to base R?

Remainder Method: divide value by R until it equals zero value in base R = remainders backwards Powers Method: divide value by R^n until it equals zero value in base R = how many times it divides into each n

What is a signed number?

a number that uses a bit to distinguish between negative and non-negative numbers

How do you know if you have overflow in two's complement signed addition?

add two positive numbers and get a negative or add two negative numbers and get a positive

What is -1 in two's complement?

all ones

How many things can you store in N bits?

at most 2^N things

What is integer overflow?

attempting to store a larger value to a variable than the variable's size allows

How do you know if you have overflow in unsigned binary addition?

carried over to another bit - definitely overflow

How do you compute the decimal value for an N-bit signed magnitude sequence?

compute the value of digits (skipping the left-most) and then check the left-most bit to find the sign

What does an individual bit in a base 2 number store?

either a 0 or a 1

How would you extend an unsigned value?

extend zeros to the left (always positive)

How would you negate a value in two's complement?

flip all of the bits and add one

What is the algorithm for 2's complement?

flip all the bits, add one (either direction)

How do you convert from binary to octal?

group the bits in sets of 3 and convert the values (8 = 2^3)

How do you convert from binary to hexadecimal?

group the bits in sets of 4 and convert the values (16 = 2^4)

How would you assign an 8 bit number to a 16 bit representation?

if it's unsigned add 8 zeros to the front, if it's signed add eight more bits matching the signed bit to the front

How are memory addresses stored in the hardware?

in binary (frequently displayed in hexadecimal though)

What is attempting to store a larger value to a variable than the variable's size allows called?

integer overflow

What are the two major drawbacks to signed magnitude?

it contains a negative and a positive zero, inconvenient discontinuity between negative values and zero (-7+1=0?)

How does fixed-point work in binary?

it extends the binary integer format

How does the decimal point work in fixed-point representation?

it remains fixed and cannot be changed

How does floating-point work in binary?

it represents a large range of values at the cost of some extra complexity

What happens when a finite unsigned number overflows?

it rolls over back to zero

How does signed magnitude work?

it treats the high-order (or left-most) bit exclusively as a sign bit, the absolute value of the number isn't changed

What does it mean if a floating-point number starts with a 1?

it's negative

What does it mean if a floating-point number starts with a 0?

it's positive

How would you negate a signed magnitude sequence?

just flip the left-most (most significant) bit

What do you do to the mantissa/significand to determine the number's value?

multiply it be 2^(exponent - bias) and add the sign bit

How would you perform subtraction on binary numbers?

negate the second number (by flipping the bits and adding one) then add

When is signed magnitude used?

never, not since the 1960s

Define positive.

non-zero and non-negative

What is the prefix for a decimal?

none

What are signed numbers?

positive, negative, or zero

What do the digits after the binary point represent in fixed-point representation?

powers of two raised to a negative value (1/2, 1/4, 1/8,1/16)

What are some pros and cons to floating point numbers?

pros: additional flexibility, represents a wide range of values cons: can't precisely represent every possible value, rounding problems

What does the significand/mantissa in a floating-point number do?

represents the foundation for the value, has an implied 1 binary point before it, gets multiplied to achieve the value

Decode the following float, floating-point number: 0b11000001101101000000000000000000

sign: - exponent: 131-127=4 mantissa: 1/4+1/8+1/32 -1.01101 * 2^4 -10110.1 -(16+6+.5) -22.5

What are the main differences between signed magnitude and two's complement?

signed magnitude has two zeros and in two's complement you have to flip the digits and add one to figure out the value of a negative number

How many positive values does n bits yield?

subtract one for zero

What is the maximum value for an unsigned binary number of n bits?

subtract one for zero

In C, what happens when you declare an int?

the compiler interprets the variable as a signed two's complement integer

What happens when your operation causes the number to use more bits than it was allocated for?

the extra bit(s) get truncated (rounding)

What usually happens when dividing binary fractions?

the fractional portion gets truncated

How does two's complement work?

the high-order (left-most) bit indicates whether or not it's negative, then you just flip the signs and add one

Which bits are the most important in the mantissa/significand?

the left-most

Which bit is the most significant bit in a signed number?

the left-most bit (also known as the high-order bit)

How does the decimal point work in floating-point representation?

the position of the value's binary point is not fixed into a predefined point

Why must a programmer choose how many bits to dedicate to a variable, prior to storing it?

the program needs to allocate storage space for it, hardware storage has finite capacity, and programs often move data from one storage device to another

In C, what do the low-order 23 bits represent in a float?

the significand (or mantissa)

In a floating point number, what section has the most bits?

the significand (or mantissa)

How do arithmetic procedures change for signed vs unsigned numbers?

they don't

How do compilers turn 4-bit sequences into 8-bit sequences?

they extend the high-order bit and prepend it four times (0b1011->0b11111011 or 0b0100->0b00000100)

How would you declare an integer unsigned in C?

unsigned int

When is overflow possible with basic binary arithmetic (two's complement)?

when add two positive (or two negative) numbers

When is overflow not possible?

when adding a negative and a positive number

When is overflow possible?

when adding two positive or two negative numbers

When is a carry out from a high-order bit indicative of an overflow problem?

when adding, not necessarily when subtracting

For a finite unsigned number, what happens when you subtract one from zero?

you get the maximum number

Define non-negative.

zero and positive numbers

What are unsigned numbers?

zero or positive (nonnegative numbers)


संबंधित स्टडी सेट्स

US History Topic 10 Practice Quiz

View Set

ARALING PANLIPUNAN: PAGKAMAMAMAYAN, KARAPATANG PANTAO, GAWAING PANSIBIKO, AT PATICIPATORY GOVERNANCE

View Set

Examen de mi-étape 3 sciences SYSTÈME LYMPHATIQUE

View Set

Accounting Issues: Chapter 4 - Communicating Results and Visualizations

View Set

Chapter 65: Assessment of Neurologic Function

View Set

Genetics - Ch. 13 Gene Mutations, Transposable Elements, & DNA Repair

View Set

Finance 331 Test 3 Conceptual Practice

View Set