@grue@lemmy.world
link
fedilink
English
101Y

Oh, for fuck’s sake.

Your thumb is not your zeroth finger; it’s your first finger.

Starting from zero is for situations when you’re counting the left (or first) edge of containers used to hold items. For example, if you wanted to count the number of balls you could hold in the spaces between your fingers, you start with 0 because the number of balls you can hold between your thumb and {} is 0.

macniel
link
fedilink
41Y

But length of container gives you for example 3, and it has a size of 4. Explain that.

length measures the spaces between the spaces between your fingers, so you can fit 3 balls between the 4 balls between your fingers

Indices vs offsets. A lot of people mistake the two because they took CS 101 and thought it was so cool to say I sTaRt cOuNtInG fRoM zErO.

darcy
link
fedilink
61Y

bro has never heard of a joke

There you are, our CS doctor.

You’re angry

@spauldo@lemmy.ml
link
fedilink
English
31Y

Also indexes. Once you’ve been bitten enough by off-by-one errors this actually becomes a pretty handy double-check.

darcy
link
fedilink
11Y

indexes in memory can be thought of as the address of the leftmost bit in a byte (container)

@spauldo@lemmy.ml
link
fedilink
English
21Y

Sorry, too busy counting digital outputs on Modicon PLCs to think about that stuff.

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 61 users / day
  • 247 users / week
  • 417 users / month
  • 2.88K users / 6 months
  • 1 subscriber
  • 1.53K Posts
  • 33.9K Comments
  • Modlog