today I'm thinking about why it's useful for someone who mostly works in higher-level languages (python, JS, scala, etc) to understand how computers represent things in bytes.

some ideas I have so far:

- reading the output of strace
- doing back-of-the-envelope storage calculations
- choosing the right size for a DB primary key (to prevent overflow)
- knowing the limits of JS numbers
- optimizing algorithms (like knowing that multiplying by 2^n is fast)
- debugging encoding issues

what else?

I'm also curious about whether there's ever a reason to understand how two's complement works (I'm sure it's cool but I've never needed to learn it so far, only that signed and unsigned integers are different)

Follow

@b0rk If you get too high a score in a video game, sometimes end up with a large negative score instead. Same with number of lives. This behavior leaks into most programming languages: Scala, though not JS or Python. Sometimes it's a disastrous bug that adding up positive numbers can give you a negative number, especially a large one.

10s-complement is useful for mental arithmetic. 651 - 382? Well, use the 10s-complement of 382: 618. 651 + 618 = 1269, drop the carry, 269, 651 - 382 = 269. Easier to add mentally than subtract, for most of us.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.