0% found this document useful (0 votes)
9 views19 pages

AIT_CS_01

The document introduces a computer science course for Fall 2024, focusing on the fundamental abstractions that allow source code to be executed by computers. It covers the evolution of programming from primitive hardware and software to modern high-level languages, emphasizing the importance of understanding software's workings for better programming skills. Key concepts include binary encoding, base conversions, and how data is represented and interpreted in computing.

Uploaded by

tjjbqzyvnh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views19 pages

AIT_CS_01

The document introduces a computer science course for Fall 2024, focusing on the fundamental abstractions that allow source code to be executed by computers. It covers the evolution of programming from primitive hardware and software to modern high-level languages, emphasizing the importance of understanding software's workings for better programming skills. Key concepts include binary encoding, base conversions, and how data is represented and interpreted in computing.

Uploaded by

tjjbqzyvnh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Introduction to

Computer Science

Fall 2024

1
Introduction

● You’ll learn the key abstractions “under the hood”


○ How does your source code become something the computer understands?
○ What happens as your computer is executing one or more programs?

2
Some History

● Hardware started out quite primitive


○ Programmed with very basic instructions
■ Very tedious!
● Software was also very basic
○ Programs reflected the actual hardware they
ran on
○ Programmer had to specify each step
manually

Programmers working on the ENIAC, circa 1946.

3
Some History

● As time went on, programming became more abstract


○ Assembly language: basic set of instructions
○ Early high-level languages: C, FORTRAN, etc.
■ Data types, arrays, loops, etc.
■ Still closer to the hardware than modern
languages
○ Now: Java, Python, etc.
■ Lots of convenient features!
■ Don’t have to know much about the hardware to
program Brian Kernighan and Dennis Ritchie, creators of
the original C standard.

4
Layers of Computing

5
Course Perspective

● This course will make you a better programmer


○ Learn how software really works
■ Understand some of the abstractions that exist between hardware and software, why
they exist, and how they build upon each other
● Why is this important?
○ Better debugging
○ Better basis for evaluation performance

6
Binary

7
Base Definitions

● If we’re in base b, that means we have b possible symbols to use

○ In decimal (base 10), we have the digits 0-9

● Each digit represents a power of b

○ The rightmost digit always represents 1 (b0), and it increases as we read left

Ex: compare the number written “351” in base 10 vs base 6

102 = 100 101 = 10 100 = 1 62 = 36 61 = 6 60 = 1

3 5 1 3 5 1

In base 10, this numeral means we have 3 100s, In base 6, this numeral means we have 3 36s, 5
5 10s, and a 1. 6s, and a 1.

8
Binary

● Humans think about numbers in base 10, but computers “think” about numbers in base 2
(binary)

● A binary digit is called a bit


● A group of 4 bits is called a nibble
● A group of 8 bits is called a byte

9
Why Binary?

10
Binary and Hex

● Binary is inconvenient for humans, so computer scientists often write numbers in base
16 (hexadecimal)
○ 16 digits: 0-9, A-F
○ Why hex?
■ Easy conversion, each hex digit = 4 bits!
● 2 hex digits = 1 byte
● We use prefixes to denote common bases
○ 0b = binary
○ 0x = hex
○ No prefix = decimal

11
Base 10 Base 2 Base 16

Common Base Conversion 0 0000 0


1 0001 1
2 0010 2
● hex -> binary: translate each digit according to chart, 3 0011 3
then drop leading 0s 4 0100 4
○ Ex: 0x2D = 0b0010 1101 = 0b101101 5 0101 5

● binary -> hex: break into groups of 4 bits from right 6 0110 6
7 0111 7
to left, add leading 0s if necessary, then translate 8 1000 8
○ Ex: 0b101101 = 0b0010 1101 = 0x2D
9 1001 9
● Note: does not work for decimal conversions! 10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
12
Review Questions: Binary, Hex, and Decimal

What is the hex value of 108? Convert 0b100110110101101 to hex.


A. 0x6C
B. 0xA8
C. 0x108
D. 0x612 Convert 0x3C9 to binary.

13
Numerical Encoding

● You can represent anything countable using numbers!


○ But you need to agree on an encoding
● Computers store all data as a binary number
● Examples:
○ Decimal Integers: 0→0b0, 1→0b1, 2→0b10, etc.
○ English Letters: CSE→0x435345, yay→0x796179
○ Emojis: � �0x0, � �0x1, � �0x2, � �0x3, � �0x4, � 0x5

14
So What’s it Mean?

A sequence of bits can have many meanings!


● Consider the hex sequence 0x4E6F21
○ Possible interpretations include:
■ The decimal number 5120257
■ The real number 7.203034*10-39
■ The characters “No!”
■ The background color of this slide (sort of an olive green?)
● It’s up to the program/programmer to decide how to interpret the sequence of bits

15
Binary Encoding Example - Colors

● RGB - Red, Green Blue


○ Additive model, represent amount of each color of light
■ 1 byte (8 bits) for each color
Ex: Blue = 0x0000FF, White = 0xFFFFFF
Dark Purple = 0x7030a0

16
Binary Encoding Example - Text

● American Standard Information Exchange (ASCII)


● Unicode (international)

17
Binary Encoding Example - Files and Programs
● At the lowest level, all digital data is stored as bits!
● Layers of abstraction keep everything comprehensible to humans
○ Data/files are groups of bits interpreted by a program
○ Program is also a sequence of bits interpreted by the CPU

18
Summary
● All computer data is stored in binary
○ Humans think in decimal, have to convert between bases
○ Hex as a more human-readable base that’s easy to convert
● Binary can represent anything!
○ Program needs to know how to interpret the bits

19

You might also like