You are on page 1of 22

Computer science notes

Base of number system (radix)


- Base of a number system is equal to thee total number of digits available in that
number system

- For example: radix of binary is 2, hexadecimal is 16 etc

Binary System
- Binary number is not showing: 0

- Binary number is showing: 1

- On: 1

- Off:0

- Single digit is calles a bit

Number system
- 4 types: Binary, Decimal, octal and Hexadecimal number systems

- 10 digits: 1, 2, 3, 4, 5, 6, 7, 8, 9, 0

- Only a 10 digit number can be made without repeating any of the digits

- Any number can be made using these 10 digits

Converting from denary to


binary
- Ans: (107) base 10= (1101011) base
2

- Write the numbers from the bottom


of the table

1
Converting from Binary to Denary

OR

2
- 1 bit- 0 or single

- 2 bit- make any binary number

- 4 bit- nibble

- 8 bit- 1 byte

Hexadecimal number system


- Generally for colours

- Base 16 system so it needs to use 16 different values to represent each digit

- Numbers 0 to 9 and letters A to F are used (A to F is used to numbers: 10-15)

- Table of numbers in hexadecimal code:

- Pattern: 1st row on left has 8 zeros then 8 ones, then the 2nd row from the left
has 4 zeros and 4 ones, 3rd row from left has 2 zeros and 2 ones, last row from
left has 1 zero and 1 one

- Converting from Binary to Hexadecimal

3
- If its an odd number, add 0 to the left so 1 0001 0111 becomes 0001
0001 0111

Hexadecimal to Binary

4
Hexadecimal to denary

Denary to Hexadecimal

5
Measurement of the size of computer memories
- A binary digit is commonly referred to as a BIT

- 8 bits make a BYTE

- The byte is the smallest unit of memory in a computer

- Some computers use larger bytes but they are always multiples of 8. For examine: 16- bit
systems and 32-bit systems

International Electrotechnical Commission (IEC)


- 1 kibibyte (1 KiB)=1024 bytes

- 1 mebibyte (1MiB)-1048576 bytes

Binary Addition
- Rules
• 0+0=0

• 0+1=1

• 1+0=1

• 1+1=0 and carry 1

• 1+1+1= 1 and carry 1

6
Overflow Errors
- If the addition of the leftmost bits (the bits in the column with place value) produces a
carry, then the result will exceed the available number of bits. This is called an overflow
error

*Hexadecimal is more human friendly as compared to binary. Hexadecimal is easier to


understand than binary, Programmers often use hexadecimal to represent binary
values as they are similar to write and check than when using binary

Usage of hexadecimal
- Colour codes

- MAC Address

- Error codes

- IPv6 addresses

MAC Address
- A number which uniquely identifies a device on the Internet.

- It relates to the network interface card (NIC) inside the device

- The number is given by the manufacturer

- First 6 digits identity the company/ manufacturer

- Later 6 digits are given as the serial number.

- These are given in hexadecimal format

Assembly code and memory dumps


- Hexadecimals have advantage over binary due to:

• They are easier and faster to work with, taking up less space

• Mistakes are less likely and easier to trace/debug\

7
ASCII (American Standard Code for Information Interchange)
- Uses 8 bits to store each character

- 8 bit is used as a check bit so only 7 but is available to store each character

- Total of 2^7=128 different values

- Each key on the keyboard has a numerical value

- To increase the ASCII value without looking at the table, get the difference,
convert it into binary and add/subtract it.

- OR take the value, covert binary to denary, subtract/ add the difference (deanery),
convert to binary again, thats the ASCII key

8
- *when counting ASCII characters, count the enter key and the space key as
well

UNICODE
- Unicode Transformation Formats (UTF)

- UTF-8, UTF-16 and UTF-32 etc

- It can expand depending on the character

- UNICODE supports ALL languages in the world (all characters symbols, etc)

- UNICODE takes much more space than ASCII

Logic Gates
- The transistors can be built into circuit called logic gates

- They can take one or more inputs and either produce an output or not according
to the way they have been wired up

Numbers
- Signed and Unsigned

- Unsigned: Binary numbers etc

- Signed:

• A positive or negative number.

9
• The left most bit will be the sign (Positive:0, negative:1)

• The rest of the numbers will have the value (magnitude).

• For example: -7 will be 1111, +7 will be 0111.

• Most significant bit(MSB): stores sign, left most bit.

• Least Significant bit (LSB): Right most bit (n-1)

• For example: 1001 represents -1, 1101 represents -5

Number Extension
1. Sign goes on extreme left

2. Magnitude goes on the right

3. 0 comes in between where the spaces are empty in positive number

4. If the number is negative fill with 1

10

1’s complement
- Positive numbers:
• same as signed magnitude.

• For example: +7 in signed magnitude is 0111, 1’s complement is the same

- Negative numbers:
1. - becomes + (Left most bit doesn’t change in answer)

2. 2. write number in signed magnitude

3. write complement (change 0 to 1 and 1 to 0)

- For example: -7 unsigned magnitude is 1 111, in 1’s complement its 1 000

11
2’s complement
- 15 combinations because +0 and -0 is same

- 1000 combination is missing

- Represents -8 as well whereas signed magnitude and 1’s complement don't

- Positive numbers:

• Have the same value as the signed magnitude and 1’s complement

• For example: 0101 will remain the same in 2’s complement

- Negative
numbers:

• Take 1’s
complement

• Inverse

• Add 1

12
https://www.exploringbinary.com/twos-complement-converter/

13
14
Sounds
- Analogue waves: constantly changing. For example: the sound coming out of
your mouth right now, smooth,

- Digital sounds: used by computers and most of the music today, discrete signals,
complex series of ‘on and off instructions, square and discrete

- A computer must convert analogue sound to digital in order to represent the


sound using binary.

- Sampling: to represent an analogue sound wave in digital format

- Takes measurements of the sound based on the number of bits used to record
each measurement, as the number go bits increase, the accuracy increases as
well. This is also called sample resolution

- The number of measurements taken per second (sample rate)

- The computer system will take a sample of the analogue wave a specified
number of times every second (sample rate), and record each measurement using
a predetermined number of bits (sample resolution).

- The sample rate affects the detail in the digital sample because the more times
an analogue wave is sampled, the more data is gathered.

- The closer the digital sample is to the analogue sound wave, the clearer and more
detailed it will be.

- There are two ways in which a computer system can improve audio quality:

1. The number of times we sample the sound (sample rate)

2. The more accurately the wave height is sampled (sample resolution)

If both of these are increased, the computer system will store more data, and thus
the file containing the audio will be much larger.

The higher the sample rate, and the higher the sample resolution, the more detailed
the sound will be, but the file used to save the sound will be much larger.

15
Images
- A pixel – a picture element – is the smallest identifiable piece of an image.

- Each pixel in an image is given a binary number which relates to a specific colour.

- Computers create images by assigning a binary value to a pixel

- A digital image is made up of a collection of these pixels, stored as binary, which


is then processed by a computer system to display the image.

- Image resolution refers to the number of pixels within an image, and this is
normally described using the width and height of the image.

- For example, a resolution of 1080 × 720 means that an image is 1080 pixels wide
and 720 pixels high.

- If we increase the bit depth – the number of bits per pixel – we can achieve more
colour combinations:

2 bits per pixel 4 colours

3 bits per pixel 8 colours

42 bits per pixel 16 colours

- If we use more colours our image will become more detailed

- The resolution of an image is the number of pixels in the width × the height of the
image.

- The bit depth of the image refers to how many bits are used to store the colours
in each pixel of the image.

- The higher the bit depth, and the higher the resolution, the more data has to be
stored. This means the file will be larger, but with a clearer and more vivid image.

16
Data Storage
- In the form of bits

Calculating the size of a file


- The size of an image= Image resolution (in pixels) X colour depth (in bits)

- The size of a mono sound file: sample rate (in Hz) X sample resolution (in bits) X
length of sample (in secs)

- For a stereo sound file, multiply the result by 2

- Kilo hertz to hertz is x1000

17

*Algorithm: A sequence of tasks given to come to an answer

Lossy Compression
- There is some loss of data

- Some unnecessary bits are reduced from the information to reduce file size

- We cannot get back the original film once it has been compressed

Loseless Compression
- It checks for the pattern in the file

- You can regenerate the original file

- No loss of data

- If there is no pattern in the file, the file size may increase as the algorithm makes
its own pattern

Lossy Compression Loseless Compression

Loss of data No loss of data

Cannot get the original file back Can get the original file back by regenerating

Removes bits for compression Checks for patterns and groups similar data
together for compress

Loss of data is permanent File can be reverted back

Reduces file size by a lot Reduces file size less than lossy

Quality compromised Quality not compromised

Image, Audio but not text Text, Image, Audio

18
- Lossless technique is better in most ways

Logic Gates
- An idealised model of computation or physical electronic devices implementing a
boolean function, a logical operation performed on one or more binary inputs that
produces a single binary output

- Number of possible combinations= 2 raised to the power number of inputs

- Output is always 1

- NOT gate
- Only not gate has one input and one output (only 2 combinations). All other gates
have two inputs and one output

- Makes it the opposite

- Formula for Not gate is x bar (- on top)

- AND gate
- AND is represented by .

- AND gate is multiplication

- If one is true and one is false, the answer will be false

- OR gate
- OR operation is represented by + sign

- OR gate is addition

- If one is true and one is false, the answer will be true

19
- NOR gate
- Combination of AND and OR gate

- Any one condition or both are true, answer is false

- Both are false, output will be true (any other combinations is false)

- NAND gate
- Combination of AND and NOT gate

- Both conditions true, result will be false

- All other conditions either one is true/false or both are false, answer will be true

- XOR gate
- NOT, AND and OR gate

- If both are true or both are false, answer will be false

- Only when one is true and one is false, answer will be true

20
Truth Tables
- To trace the output from a logic gate

https://bit-calculator.com/bit-shift-calculator

https://onlinetoolz.net/
bitshift#base=10&value=-12&bits=8&steps=2&dir=l&type=log&allsteps=1

https://www.exploringbinary.com/twos-complement-converter/

Softwares
- A program that allows a person to complete a task

- Types: System software and application software

System software
- Operating system, Utility softwares, Disk Drivers, Linkers

- Programs that allow the hardware to run properly and allow the user to
communicate with the computer

- Disk Drivers are programs that make the system aware of the hardware it needs
to communicate with. For ex: a printer driver needs to be installed before printing

- Driver has code to perform a function

21
- Disk Drivers are softwares that enable one or more hardware devices to
communicate with the computers operating system

- Linkers provide an object file that allow the user to combine softwares for
example: Word with Excel

- Linker is a computer program that takes one or more object files produced by a
compiler and combines them into a single program which can be run on a
computer

- Utility Softwares are programs that help to manage, maintain and control
computer resources. For example: AntiVirus software

- Operating System provides both the environment in which applications can be


run and a useable interface between the user and computer (hardware)

- Functions of Operating System: Multitasking, Provides platform for running


application software, Management of user accounts, managing files, hardware
peripheral management, memory management, Interrupt handling routines,
Security (manages log on, passwords), human computer interface (HCI) (GUI and
CLI)

Application Softwares
- Word Processors (MS Word), Video Editing Softwares (iMovie), Spread Sheets
(Excel), Database (MS Access, SQL), Photo Editing softwares (Adobe
Photoshop), Control and Measuring Softwares (Measure), Graphics Softwares
and Apps etc

- Application Softwares are categorised based on purpose

- Application Softwares: Programs that allow the user to do a specific task

- Application Softwares directly work with hardware

https://computer.howstuffworks.com/operating-system2.htm

22

You might also like