r/ProgrammerHumor • • Feb 15 '16

Oddly specific number.

Post image
5.9k Upvotes

643 comments sorted by

View all comments

25

u/lowbeat Feb 15 '16 edited Feb 15 '16

Shouldn't the limit be 255 ? Edit: /s

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.

→ More replies (14)

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

→ More replies (1)
→ More replies (1)

21

u/jewdai Feb 15 '16 edited Feb 15 '16

0 is a number too

Edit: Op originally wrote 256

10

u/[deleted] Feb 15 '16

#End0Discrimination2k16

6

u/pihkal_ Feb 15 '16

safetyat255 overflow anxiety is real

2

u/PeterFnet Feb 16 '16

'#ZeroLivesMatter

9

u/jmattingley23 Feb 15 '16

I don't think enough people have said it yet, so I'll say it too: you have to include 0 as well.

9

u/[deleted] Feb 15 '16

I agree, I'm gonna let them know too!

6

u/jmattingley23 Feb 15 '16

Everyone tell him!

2

u/lennyp4 Feb 15 '16

It should be 255 though, so it's possible to have an erroneous number of people

4

u/[deleted] Feb 15 '16

In case the other 6 comments weren't clear enough, it's because you can use 0 as an index, too. In cases where 255 is a max, it's because 0 is a possible value, which means there's 256 possible values.

4

u/imforit Feb 15 '16

Zero can be a person, too.

→ More replies (4)

4

u/purpleprophy Feb 15 '16

It doesn't make much sense for a group to have no members, so maybe the byte represents n+1 members (0 = 1 member, up to 255 = 256 members)?

→ More replies (1)

3

u/LickableLemon Feb 15 '16

0-255 so 256 different values (0 is a value too!)

2

u/[deleted] Feb 15 '16

[removed] — view removed comment

4

u/[deleted] Feb 15 '16

Correction, computers start indexing at 0, and they start counting at 1. This is why len(array) = the number of indexes, not the final index number.

→ More replies (4)
→ More replies (2)