represent 2:
10
represent 3:
11
represent 4:
100
represent 5:
101
represent 6:
110
represent 7:
111
We can find that the last digit represents whether the number is odd or even. 0 represents even and 1 represents odd. The second last digit is to divided the number by four so and so forth.
Therefore, we can get a rule that b7:128 b6: 64 b5: 32 b4: 16 b3:8 b2: 4 b1:2 b0:1
So when we can use bits to find out the exact number. For example:
01100110:128*0 +64*1+32*1+16*0+8*0+4*1+2*1+0*1
In reverse, we can transfer exact number into 8-bit binary with two methods.
Represent 104 as an 8-bit binary:
(< 104 128) so start with 0
(>= 104 64) so next bit is 1
(- 104 64): 40
(>= 40 32): so next bit is 1
(-40 32): 8
(< 16 8): so next bit is 0
(>= 8 8): so next bit is 1
(-8 8):0
so 4, 2 and the 1 bit are p
#b01101000
Alternatively get the bit from the right to the left:
104 is even, so right-most bit is 0
(quotient 104 2): 52
even, so next bit is 0
(quotient 52 2): 26
even, so next bit is 0
(quotient 26 2): 13
odd, so next bit is 1
(quotient 13 2): 6
even, so next bit is 0
We can also represents number into characters. In Dr. Racket, if we put #\a, we can find the exact numbers to represent a character.
e.g. integer->char 104 à
#\h
Also we can use it to represent colours. (make-color red green blue transparency) There are 0-255 levels. When these mixtures combined, it may make different colours. For example, when we put (255 255 255 0) in the Dr. Racket, we will get the white and transparent colour. In this week's lecture and quiz, we will cover colour list. This is a list that all the colours to make a picture.
This week, we begin to touch on the second part of the wikipedia assignment. At first, I am quite confident with the assignment. Now, I find that it is difficult for me to create a new sandbox for my assignment. I plan to figure out this by reading the instruction and policy in wikipedia editing page. I will begin to do this as soon as possible and discuss my approaches to figure out the problems I have when I do the assignments in my next post.
