CS50-01-Scratch: 01-Getting started with Data Representation
Day 1 of CS50's Introduction to Computer Science here I noted keypoints of the very first part of the course how to represent Data and how computer interprets it
Computer Science
Computer science is used to solve problems with some techniques and methods.
With the help of computational thinking, we can think like a computer to solve problems using algorithms.
In algorithms, we can input data and design algorithms to solve specific problems and give solutions as output
Binary system
By far we can count 31 numbers by hand
The computer is an electro-mechanical device that requires electricity to operate
The state where electric current is there is 1 and is not is 0.
In decimal, we can count each digit as in number multiplied by the power of 10 similarly, we can represent digits in the power of 2
ex - 123 -> 1x10^2 + 2x10^1 + 3x10^0 -> 100 + 20 + 3 == 123
binary -> 4 -> 100 -> 1x2^2 + 0x2^1 + 0x2^0 == 4 + 0 + 0 => 4 -> 100
Bit -> One bit represents 0 or 1
Byte -> Collection of 8 bits -> 2^8 -> 25611 numbers can be presented from range 0-255
For negative 8th bit represents the negative number if 0 -> positive and 1 -> negative
so the range of is (2^(n-1) - 2^(n-1)-1) i.e. (-128 to 127)
ASCII and Unicode representation
Ascii code is the human convention to represent each alphabet and symbol as a number
Unicode is a superset of ASCII which not only relies on 8 bits but also can use 16 or 24 sometimes even 32 bits if required per character which enables us to use roughly 4 billion characters
This leads to a large no of calculations so in Unicode we use the hexadecimal number system
so for example in the yellow thumbs-up emoji, we use (๐) U+1F44D as Unicode, so for another skin tone we don't change the emoji Unicode instead we add the color cod like U+1F44D U+1F3FD (๐๐ฟ)
Same for couple love we have the same Unicode we just add code accordingly like man-woman, man-man, women-women, etc.
Ex-(๐ง๐ปโโค๏ธโ๐ง๐ฝ๐) Unicode for heart and man will be the same and code gets added to it when we change color or man to women. U+.... U+200D U+.... U+200D U+....
Here U+200D is zero-width-joiners which joins two emojis to each other
Colors
- RGB is used to associate colors, each pixel has these three numbers and every color is possible by their combination
Representation of certain meaning
As we know RGB(73,72,33) gives us light yellow but in the text it gives us Hi! and different in the case of numbers
So to interpret it correctly one should set important context
Subscribe to my newsletter
Read articles from Shubham Mete directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Shubham Mete
Shubham Mete
I am a student pursing Bachelors in Computer Science Specialization in Artificial Intelligence and Data Science I am from Pune, India