So my point in telling you about my journey into the unknown world of bytes n' bits. I will be writing a simple flash card program that has the notes from all the books and chapters I read. This program will basically take text files and turn them into flash cards. As I develop it I will post the notes I make from the material. So here are the first half of my notes
Q. who is the author of write great code?A. Randal Hyde
Q.How do you convert Hexadecimal representation of a number to binary?
A.To convert the hexadecimal representation of a number into binary, substitute the corresponding four binary bits for each hexadecimal digit.
Q. How do you convert the binary representation of a number into hexadecimal?
A.The first step is to pad the binary number with zeros to make sure it is a multiple of four bits long. For example, given the binary number 1011001010, the first step would be to add two zero bits to the left of the number so that it contains 12 bits without changing its value. The result is 001011001010. The next step is to separate the binary value into groups of four bits: 0010_1100_1010. The last step is to convert the binary digits to hexadecimal.
Q.What is a nibble?
A. A nibble is a collection of four bits. Most computer systems do not provide efficient access to nibbles in memory. However, nibbles are interesting to us because it takes exactly one nibble to represent a single hexadecimal digit.
Q. What is a byte?
A. A byte is eight bits and it is the smallest addressable data item on many CPUs. That is, the CPU can efficiently retrieve data on an 8-bit boundary from memory. For this reason, the smallest data type that many languages support consumes one byte of memory (regardless of the actual number of bits the data type requires).
Q.what us a word?
A.The term
word has a different meaning depending on the CPU. On some CPUs a word is a 16-bit object. On others a word is a 32-bit or 64-bit object. In this text, we'll adopt the 80x86 terminology and define a word to be a 16-bit quantity. Like bytes, we'll number the bits in a word starting with bit number zero for the LO bit and work our way up to the HO bit (bit 15), as in
Figure 2-4. When referencing the other bits in a word, use their bit position number.
Q. What is double word?
A.A double word is exactly what its name implies, a pair of words (sometimes you will see 'double word' abbreviated as 'dword'). Therefore, a double-word quantity is 32 bits long.
Q. How many values can you represent with a n-bit string?
A. up to 2n different values
Q. How many signed values can you represent with a n-bit string?
A. In general, with n bits we can represent the signed values in the range −2n−1 to +2n−1−1.
Q. How does the 2's compliment system represent signed numbers?
A. The two's complement system uses the HO bit as a sign bit. If the HO bit is zero, the number is non-negative; if the HO bit is one, the number is negative
Q. how do you negate a 2's compliment number?
A. To negate a two's complement number, you can use the following algorithm:
Invert all the bits in the number, that is, change all the zeros to ones and all the ones to zeros.
Add one to the inverted result (ignoring any overflow).
Q. How do you -negate a negative 2's compliment number?
A. The same operation for vice versa
To negate a two's complement number, you can use the following algorithm:
Invert all the bits in the number, that is, change all the zeros to ones and all the ones to zeros.
Add one to the inverted result (ignoring any overflow).
Q. What happens if the LO n bits of a binary number all contain zero
A. The number is equally divisible by 2n
Q. What happens if the binary number contains a one in the bit position n and zeros everywhere else?
A. that number is equall to 2n
Q. What happens if you shift all the bits in a binary number to the left one position?
A. the number gets multiplied by two
Q. What happens if you shift all the bits in a binary number to the right one position?
A. Shifting all the bits of an unsigned binary number to the right by one position effectively divides that number by two.(this does not apply to signed integer values). Odd numbers are rounded down.
Q.
A. Multiplying two n-bit binary values together may require as many as 2*n bits to hold the result.
Inverting all the bits in a binary number (that is, changing all the zeros to ones and all the ones to zeros) is the same thing as negating (changing the sign) of the value and then subtracting one from the result.
Incrementing (adding one to) the largest unsigned binary value for a given number of bits always produces a value of zero.
Decrementing (subtracting one from) zero always produces the largest unsigned binary value for a given number of bits.
An n-bit value provides 2n unique combinations of those bits.
The value 2n−1 contains n bits, each containing the value one.