Bits and Bytes Flashcards
What is a byte?
It is a group of 8 bits that can be individually addressable.
What is a bit?
Holds 0 or 1
What is a word?
● It is a group of 4 bytes (32 bit architecture) or
● It is a group of 8 bytes (64 bit architectures)
● The address of a word is aligned to either 4 or 8 bytes respectively (multiple of 4 or 8 bytes).
What is memory mapped I/O?
When device registers are mapped to
memory.
A bit can represent the state of the device.
What are 3 examples of Character Encodings broken question
Who created Extended Binary Coded Decimal Interchange Format?
● It was created by IBM in the 1960s
● No longer in use except in some IBM
mainframes
What does ASCII stand for?
American Standard Code for Information
Exchange
How many bits/values does ASCII use?
It uses 7 bits or 128 values
What does ascii encode?
The English alphabet
How many bits does Unicode use?
16 bits (2 bytes)
What does unicode encode?
Languages from all around the world
What languages use unicode internally for strings?
Java and C#
How does Pascal represent strings?
The first byte is the length of the string
How do you perform math in binary? (Addition, Subtraction, Multiplication, Division)
Same as decimal, just with binary digits
What ways are Negative Binary numbers represented?
● Sign and Magnitude
● 1-complement
● 2-complement
How does Sign and Magnitude
Representation work?
What is the value of 10000101?
1 bit for sign, 1 means negative, rest of the bits for absolute value.
Value of 10000101 is -5. first one means negative
How does 1-Complement work?
What is the value of 11111110
Negative numbers are obtained by inverting all bits.
11111110 is -1. invert all 00000001, neg of that
How does 2-Complement work?
What is the value of 5 in binary for 2-Com?
Negative numbers are obtained by
subtracting 1 from the positive number and inverting the result.
11111011
Why is 2-Complements widely used?
because the same piece of hardware used
for positive numbers can be used for negative numbers:
How does right shift»_space; change for signed vs unsigned ints?
if signed and the int is negative, 1s will be added, this is called “signed extension”
What do bitwise operations |, &, ^, ~ all do?
bitwise or, and, xor, not on each bit
How to check if bit x is set?
shift bit 1 x units to the left. Use & on shifted bit and comparing int.
Then take result and shift x right, if equal to 1 return true, found set bit
How to set bit?
Use | with desired bit
How does floating point representation work?
Store both the exponent and mantissa
ex” 1.101x2^-010
What are the two representations for real numbers?
Fixed point numbers and
Floating Point Numbers:
How do fixed point numbers work for real numbers?
Fixed number of bits for both integer and mantissa.
N.M – N bits for integer part and M bits for mantissa.
Example: 16 bit real number N =8 bits, M = 8 bits
Problem: Range of numbers is small. N=8 bits can
represent therange -128 to +127
+127=01111111=+127
-128=~(10000000-1)=-~(01111111)=10000000=-128
How do floating point numbers work for real numbers?
The bits allocated for integer part and mantissa is variable.
Example= N.M where N+M =16bits
● Decimal point moves. Improved range but complex
What is the most common Floating Point Representation standard?
IEEE-754 standard
What order is Little Endian?
Least significant byte of the integer
is in the lowest memory location.
What order is Big Endian?
Most significant byte of the integer is
in the lowest memory location
How can you test if Little Endian?
cast little int pointer to char, if value of char is int value then little endian.
What is the size of integers floats and pointers and doubles in 32 bit architecture?
4 bytes for everything but doubles are 8
what is the size of pointers in 64 bit architecture?
8 bytes
struct {
char ch1;
int r;
char ch2;
char * a;
} x;
What is the size of the above structure in 64 bit architecture
24 bytes