(1) Convert the 24-bit color code: R-212, G-107, B-87 into a 6-hexadecimal-digi
ID: 3704176 • Letter: #
Question
(1) Convert the 24-bit color code: R-212, G-107, B-87 into a 6-hexadecimal-digi e "#rggbb", color code for html (Hyper Text Markup Language). Hint, convert R, G and B separately. (2) Convert the base-10 integer, 19663489, into a 8-hexadecimal-digit number (pad with zeroes in the front to make 8 hex-digits). (3) Convert a base-10 number, arbitrarily chosen, into a 32-bit IEEE single precision number (8-bit excess-127 exponent, 23(+)-bit normalized fraction) 4) Convert a base-10 number, arbitrarily chosen, into a 64-bit IEEE double precision number (1-bit excess-1023 exponent, 52(+1)-bit normalized fraction). (5) (a) Convert the base-10 number, 0.47, into a binary number. Cut the answer off with 8 bits after the decimal point. Round the result if the next bit is a 1. 0.47 (b) What exactly, in base-10, does the binary number in part (a) represent? Write with 7 digits accuracy what it is 0.47 ? (6) Ifonly 12 bits are available after the decimal point, What exactly, in base-10, does the converted binary number of 0.7 represent? Write with 8 digits accuracy what the approximate value is. 0.7Explanation / Answer
1. RGB TO HEX
take value of R
R=212
Divide it by 16 and multiply the fractional part with 16 and take both values
212/16= 13.25
We took 13 as D in hex and multiply 0.25*16= 4
Value we got = D4
Similarly for G and B also
G= 107/16= 6.6875
0.6895*16= 11.032
0.032*16= 0.512
Value= 6 B
Similarly for B
B= 87/16= 5.4375
0.4375*16= 7
Value= 57
Hex value for (R,G,B)(212,107,87)= D46B57
2. Steps to calculate decimal (base 10) to hexadecimal:
a. Divide the number by 16
b. Get the integer quotient for the next iteration.
c. Get the remainder for the hex digit.
d. Repeat the steps until the quotient is equal to 0.
19663489/16 rem: 1 quo: 1228968
1228968/16 rem: 8 quo: 76810
76810/16 rem: 10 quo: 4800
4800/16 rem:0 quo: 300
300/16 rem: 12 quo: 18
18/16 rem: 2 quo: 1
Then the hex value : 12C(C for 12)0A(A for 10)81
:12C0A81
4. Suppose taken base 10 number= 675
Divide the number repeatedly by 2, keeping track of each reminder , until we get a quotient that is equal to zero
division= quotient+ remainder
675/2= 337+1
337/2= 168+1
168/2= 84+0
84/2= 42+0
42/2= 21+0
21/2= 10+1
10/2= 5+0
5/2= 2+1
2/2= 1+0
1/2= 0+1
Construct the base 2 representation of the integer part of the number by taking all the remainder starting from the bottom of the list constructed above:
1010100011
Normalise the binary representation of the number shifting the decimal mark 9 position to the left so that only one non zero digit remains to the left of it:
1.010100011*2 in power of 9
Upto this there are following elements that would feed into the 64 bit double precision IEEE 754 binary floating point representation:
Sign: 0 ( as positive number)
Exponent:9
Mantissa: 1.010100011
Adjust the exponent in 11 bit excess notation and then convert it from decimal( base 10) to 11 bit binary by using the same technique of repeatedly dividing by 2:
= 1032(base 10)
Division = quotient+ remainder
1032/2= 516+0
....
= 10000001000( base 2)
Normalise mantissa, remove the leftmost leading but,since it's always 1 then adjust its length to 52 bits by adding the necessary number of zeroes to the right
Mantissa (normalised): 1.0101000110000000000000000000000000000000000000000000=01010011000 0000000000000000000000000000000000000000
675(base 10)= 0101000110000000000000000000000000000000000000000000(64 bit IEEE 754)
5. a 0.46= 0.01111000010100011111=0.01111000(round off)
b. 0.47= 0.4700003
6.0.7 = 0.10110011001100110011
With 8 digits the decimal value is given below
0.101100110011= 0.69995117
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.