summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2023-07-12 10:09:13 -0400
committerAdam T. Carpenter <atc@53hor.net>2023-07-12 10:09:13 -0400
commitcbfbfcf897552f3f162572d6c3fa50b84e26e3e1 (patch)
tree653534a2aec4ffea68737f6ea8da6c7923764ebe
parent4df22583f7ce3cf74c2e1bcfa357eb081e8fa4ce (diff)
downloadcps-rust-cbfbfcf897552f3f162572d6c3fa50b84e26e3e1.tar.xz
cps-rust-cbfbfcf897552f3f162572d6c3fa50b84e26e3e1.zip
feat: finish and record 00 and 01
-rwxr-xr-x00/readme.md8
-rwxr-xr-x01/readme.md149
2 files changed, 150 insertions, 7 deletions
diff --git a/00/readme.md b/00/readme.md
index 893a935..131a12e 100755
--- a/00/readme.md
+++ b/00/readme.md
@@ -21,8 +21,8 @@ Welcome!
# What is this course?
This course will focus on computational problem solving using Rust as a first
-language. _It aims to provide students with the knowledge and skills to write
-programs to solve problems._
+language. It aims to provide students with the knowledge and skills to write
+programs to solve problems.
Consider this an introductory, "101"-level computer science course on
programming fundamentals taught by Carpenter Tutoring.
@@ -67,8 +67,8 @@ language content comes from the [Rust Book](https://doc.rust-lang.org/book/).
# Who am I?
- Bachelor's of Science from College of William and Mary, majoring in CS
-- Nearly five years employed as software engineer focusing on server-side
- automation and support self-service
+- Five years employed as software engineer focusing on server-side automation
+ and support self-service
- Using Rust productively for over three years
[Bio](https://www.53hor.net/info)
diff --git a/01/readme.md b/01/readme.md
index b1bcf48..c1e0072 100755
--- a/01/readme.md
+++ b/01/readme.md
@@ -218,7 +218,7 @@ These are the building blocks of every digital computer in the world today.
---
-# Representing data
+# Representing numbers
> Bits and bytes of information, turning darkness to light.
@@ -229,7 +229,7 @@ into English essays, photographs, or 3D animated feature films?
---
-# Representing data
+# Representing numbers
Probably before grade school, you learned to count from 1 to 10 on your fingers.
Just like you, the _decimal_ number system gets its name from the ten digits it
@@ -240,8 +240,151 @@ up and start counting over again at 10.
The _decimal_ system is also called _base 10_ for this reason.
-> 735 = 7 _hundreds_ + 3 _tens_ + 5 _ones_
+```
+735 = 7 hundreds + 3 tens + 5 ones
+```
+
+We could also write this as:
+
+```
+735 = 7 * 10^2 + 2 * 10^1 + 5 * 10^0
+```
+
+Lots of other popular counting systems exist.
+
+_Sexagesimal_ uses 60 digits (0..59). It is the basis for timekeeping and
+measuring angles.
+
+## Binary numbers
+
+If we want to count with just two digits (0 and 1), we have to use a _base 2_
+system called _binary_.
+
+```
+101 = 1 * 2^2 + 0 * 2^1 + 1 * 2^0
+```
+
+101 in binary is equal to 5 in decimal.
+
+_Bits_ is shorthand for _binary digits_, or every digit in a binary number.
+
+---
+
+# Binary data
+
+With binary way we can use computers to do numeric calculations on integers and
+fractions. There are some limitations however.
+
+## Integers
+
+In mathematics, integers count upwards and downwards forever. But computers have
+limited space to organize binary numbers. For example, a 32-bit computer uses
+32-bit _words_ to represent numbers.
+
+This only allows you to represent numbers as big as `2^32`, or a little more
+than 4 billion.
+
+## Fractions (Real numbers)
+
+Representing real numbers in binary is hard. No matter how we do it, it's always
+going to be an approximation of the mathematically understood truth.
+
+```rust
+fn main() {
+ println!("{}", 1.1 + 2.2);
+}
+```
---
# Binary data
+
+There are some units worth knowing when working with binary data. You already
+know about _bits_, or _binary digits_. This is the smallest unit of measure, as
+a _bit_ is just a 0 or a 1.
+
+## Bytes
+
+_Bytes_ are chunks of 8 bits. Storage, for example, is typically calculated in
+_bytes_ e.g., 8GB of RAM is about 8 billion _bytes_.
+
+## Words
+
+Computer _words_ are made up of _bytes_. A 32-bit word is made up of 4 bytes
+(`32 = 4 * 8`).
+
+---
+
+# Representing text
+
+Since everything in a computer is stored as binary numbers, we need a way of
+mapping those numbers into letters so we can work with text.
+
+## Characters
+
+Characters are letters, printed digits, punctuation, whitespace, and unprintable
+controls used to write human-readable text on a computer.
+
+## Printable characters
+
+```
+a, b, c
+1, 2, 3
+. " ; )
+```
+
+## Unprintable characters
+
+- newline (`\n`)
+- tab (`\t`)
+- carriage return (`\r`)
+
+## Standards
+
+The first standard set, ASCII, was designed in 1963. Every character had an
+associated number:
+
+```bash
+man -P "head -25" ascii
+```
+
+---
+
+# Representing text
+
+## Unicode
+
+Today we use Unicode, or an implementation of Unicode called UTF-8 for almost
+all web pages and modern programming languages. It is a superset of ASCII with
+support for thousands of multilingual characters, mathematical symbols, and
+shapes.
+
+UTF-8 is the default for Rust and what we'll be using.
+
+```rust
+fn main() {
+ println!("Parlez-vous français?");
+}
+```
+
+---
+
+# Representing images and sound
+
+If you look closely you can see the screen you're looking at now is made up of
+many tiny squares. When combined and viewed at a distance, all of these picture
+elements make up an image.
+
+These picture elements, or _pixels_, consist of location coordinates and color.
+We can use different color _schemes_ and image _resolutions_ to create, store,
+and display different images.
+
+Sound on the other hand, is normally described as a wave. This wave equates to
+levels of air pressure our ears can detect to register that sound. We can
+approximate a wave (take a sample) with a series of heights at given intervals.
+
+To record sound, we can use microphones and digital sampling to build a wave
+approximation in the computer. To play sound back, we reproduce the wave by
+playing the sample height at the rate it was recorded. This wave is pushed out
+through the speakers and registers as the same sound we heard when we recorded
+it before.