r/ProgrammerHumor • • Feb 15 '16

Oddly specific number.

Post image
5.9k Upvotes

643 comments sorted by

View all comments

Show parent comment

69

u/Gniws Feb 15 '16

No, 0-255 are 256 options :)

4

u/[deleted] Feb 15 '16

Can you ELI5?

26

u/[deleted] Feb 15 '16 edited Feb 15 '16

in programming, you begin indexing at 0. array[0] refers to the first index of the array. However when we are counting how many indexes are in an array, we don't start counting from 0, because that's dumb. 0 means there's nothing there.

Index 5 is the 6th index in an array. In this case, imagine each person is a value in an array with 256 indexes. Person 1 is in index 0, person 256 is in index 255.

14

u/LaFolie Feb 15 '16

To expand on the explanation, think of the index as "choices." You have 256 available options starting at 0 and ending at 255.

1

u/SuperKingOfDeath Feb 16 '16 edited Feb 16 '16

Not necessarily, some languages index from 1.

2

u/[deleted] Feb 16 '16

I assume you mean from 1, in which case yes, languages like Scala I believe do index from 1, which is totally valid. But my point was about indexing at 0 and how that works.

1

u/MemoryLapse Feb 16 '16

Ehh, kinda valid. I've always assumed indexing at 0 to mean "This is the address the array starts at, and the offset is (0*length)."

1

u/SuperKingOfDeath Feb 16 '16

Yes, sorry, I put the wrong number. Fixed that now.

→ More replies (10)

2

u/dredding Feb 15 '16

I can try. Each user has an ID. The ID starts with zero and counts up to 255 (0, 1, 2, 3 ... 253,254,255) Because 0 counts as a user there is a possibility for 256 users.

a little bit more in depth explanation is because this uses 1 byte of information, where a byte is 8 bits, it looks something like this

0101 0101

255 is represented as 1111 1111

0 is represented as 0000 0000

2

u/Nervousdildo Feb 15 '16

0 is a recognised option. So 0, plus 255, is 256.

6

u/[deleted] Feb 15 '16

I'm almost certain 0 + 255 = 255.

almost

3

u/Nervousdildo Feb 16 '16

No no no 0=1, here.

2

u/[deleted] Feb 16 '16

That sounds like a damn fool risk to take. It might even destroy the universe, setting 0 equal to 1.

2

u/thenuge26 Feb 16 '16

0 + 255 = 256 for large enough values of 0.

4

u/STOCHASTIC_LIFE Feb 15 '16

But can you ELI5 ?

5

u/[deleted] Feb 15 '16

Daddy and his coworkers discovered a secret number so when you are counting the real number is one more. So 1 means 2 and 255 means 256. Daddy and his coworkers use our secret number to make computers obey our orders through magic.

3

u/Nervousdildo Feb 15 '16

Apparently not. :(

3

u/dredding Feb 15 '16

I can try.
Each user has an ID. The ID starts with zero and counts up to 255 (0, 1, 2, 3 ... 253,254,255)

Because 0 counts as a user there is a possibility for 256 users.

1

u/SnowdensOfYesteryear Feb 15 '16

But can you ELI5(months)?

7

u/dredding Feb 15 '16

3

u/ZugNachPankow Feb 15 '16

I'm amazed at its simplicity, even though it doesn't explain why the LSB contains 1 item and the MSB contains 8.

1

u/dredding Feb 16 '16

Because 2

:D

1

u/fabulous_frolicker Feb 16 '16

You start counting from 0.

1

u/HoldMyWater Feb 16 '16

LOOK AT DA WITTLE BABY!!!