Kashish Dugar

My Bits & Hex card

Today I made a card that stays on my desk. Every number on it is in my handwriting.

My Bits and Hex card

Then I used the card for three conversions:

Yesterday I also wrote “I am 9 years old.” in ASCII hex, all by myself:

49 20 61 6D 20 39 20 79 65 61 72 73 20 6F 6C 64 2E

Rust: The Twelve Days of Christmas, finished!

This is the exercise at the end of Chapter 3 of the Rust book. My program prints the whole song, all 90 lines.

fn main() {
    let gifts = ["a partridge in a pear tree", "two turtle doves", "three French hens","four calling birds", "five gold rings", "six geese a-laying", "seven swans a-swimming", "eight maids a-milking", "nine ladies dancing", "ten lords a-leaping", "eleven pipers piping", "twelve drummers drumming"];
    let days = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"];
    for day in 0..12{
        let day_c = days[day];
        println!("On the {day_c} day of Christmas my true love gave to me");
        let gift_range = (0..=day).rev();
        for gift in gift_range{
            let gift_add = gifts[gift];
             println!("{gift_add}!")
        }
    }
}

What I learned:

Rust: The String Type

My stack and heap drawing with String

Petzold, Code: From ASCII to Unicode

ASCII only has 7 bits, so 128 codes. That’s enough for English, but not for accented letters like ä. So ASCII is bad for countries in Western Europe like Finland, where Matti sir lives. ASCII can’t even write his name, Matti Rajakylä! (I needed a clue to get 128 from my card.)

I found ASCII on my own desk! My keyboard has a $ key but no ₹ key. The rupee sign isn’t in ASCII, even though I live in India. But my laptop’s 4 key has a ₹ on it, and pressing Ctrl+Shift+4 types it. That’s Unicode, not ASCII: ₹ is U+20B9. (I needed a clue for the code number.)

Unicode is better for all places. It has more bits, so it has room for more characters, even emojis. The violin emoji is U+1F3BB.

I finished Chapter 13 today.