 Shuffle Toggle OnToggle Off
 Alphabetize Toggle OnToggle Off
 Front First Toggle OnToggle Off
 Both Sides Toggle OnToggle Off
 Read Toggle OnToggle Off
Reading...
How to study your flashcards.
Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key
Up/Down arrow keys: Flip the card between the front and back.down keyup key
H key: Show hint (3rd side).h key
A key: Read text to speech.a key
Play button
Play button
30 Cards in this Set
 Front
 Back
What is the range of short?

32,768 to +32,767

Given a bit called A, what is the effect of A ^ 0

The result is A

How do you toggle a bit in a bitfield

bitfield ^ bit

How many bytes in a long?

4

How do you change the sign of a signed integer using bitwise operations?

bitwisenot the value and add 1

What is the range of unsigned short?

0 to 65,535

How do you express the value of a bit b in exponential notation

2^(b1)

What's an easy way to compute the maximum positive value of an int with bitwise operators?

(unsigned int)~0 >> 1

Given an integer x, how can you tell if it is a power of 2 using bitwise operators?

!((x1) & x)

How many bytes in a short?

2

How many bytes in an int?

4

What is the range of char?

128 to +127

What is the range of unsigned char?

0 to 255

What is the range of int? (approx ok)

2,147,483,648 to +2,147,483,647

What is the range of unsigned int? (approx ok)

0 to 4,294,967,295

What is unsigned short max expressed as hex?

0xFFFF

What is unsigned int max expressed as hex?

0xFFFFFFFF

How is the most significant bit of a int expressed in exponential notation?

2^31

How many bytes is a bool?

1

What is the character for bitwise NOT

~

What is the character for bitwise OR



What is the character for bitwise XOR

^

What is the bitwise operator for bitwise AND

&

What arithmetic operation is the equivalent of the leftshift operator (i.e. <<)

Multiplying by two to the power of

What arithmetic operation is the equivalent of the rightshift operator (i.e. >>)

Dividing by two to the power of

How to you clear a bit in a bitfield

bitfield & ~bit

Given a bit called A, what is the effect of A ^ 1

The result is the A flipped

Given an ingeger x, how to you find it's twoscomplement using bitwise operators?

~x + 1

Implement the bitarray getter function given the following function signature:
bool getbit(char bitarray[], int bit) 
bool getbit(char bitarray[], int bit)
{ bitarray += bit / 8; return *bitarray & (1 << bit % 8); } 
Implement a bitarray setter function given the following signature:
void setbit(char bitarray[], int bit, bool value) 
void setbit(char bitarray[], int bit, bool value)
{ bitarray += bit / 8; if(value) { *bitarray = (1 << bit % 8); } else { *bitarray &= ~(1 << bit % 8); } } 