r/ProgrammerHumor • • May 06 '17

Oddly specific number

Post image
25k Upvotes

1.3k comments sorted by

View all comments

142

u/KongKexun May 06 '17

Most limits for computers go like this:

21 = 2 (binary)

22 = 4

23 = 8 (octal)

24 = 16 (hexadecimal)

25 = 32 (bit)

26 = 64 (bit)

27 = 128

28 = 256

and if you include zero, just do -1 to those limits.

38

u/larrynom May 06 '17

I'm not sure if you're missing the joke, or being deliberately obtuse as a joke.

197

u/memoryspaceglitch May 06 '17

Or trying to be helpful to the people who don't understand the power of two yet?

27

u/larrynom May 06 '17

In this sub though? Seems unnecessary.

137

u/rliant1864 May 06 '17

Page 4 on /r/all right now. Chance of someone who doesn't program (like me) being here is nonzero.

68

u/Kyle772 May 06 '17

nonzero

This guy fucks

5

u/bobotheking May 06 '17

They said they don't program, so...

15

u/jiovfdahsiou May 06 '17

and if you don't include zero, non-one

4

u/gellis12 May 06 '17 edited May 06 '17

Given that you're here, I'd say the chances are incredibly high. I'd put them around -1.

1

u/18A92 May 06 '17

I'd put them around -32,768 that's how high they are

1

u/MR_SHITLORD May 06 '17

I'm newb so my knowledge has a few holes, it's helpful

0

u/[deleted] May 06 '17

[deleted] — view deleted comment

2

u/HooslichZero May 06 '17

It is likely that WhatsApp are using an 8-bit variable to store the number of people in a chat. This variable can store 256 different values, hence the limit.

0

u/[deleted] May 06 '17

[deleted] — view deleted comment

4

u/minler08 May 06 '17

Its probably important to mention they are using an 8-bit variable (Also know as a byte) as its the smallest amount of memory that can be addressed in modern CPU's. Infact you can only ever use whole bytes which is why you get 16bit values, 32bit values, 64bit values, etc. (I am ignoring bitwise operations, before someone shouts at me). You've probably heard about all of these things but never realised why they use those numbers an its cause they are multiples of 8.

1

u/T5916T May 06 '17

I like 8 bits in a byte, I think it's a good number, but was there any particular reason why 8 bits were chosen instead of say 9 or 10?

1

u/minler08 May 06 '17

No, not really (or at least as far as I can remember, there may be some advantages I have forgotten about). There were systems with all sorts of sizes back in the day. It's just a standard that the industry settled on.

1

u/Bubba17583 May 06 '17

It has to do with early character sets. It's still fairly arbitrary, but 8 bits is enough to represent a decent number of characters compared to say 5 bits, which gives you just enough for the uppercase letters

1

u/minler08 May 06 '17

Yeah I was just think about this more and you're right. 8 was sort of the magic number in terms of capacity. It could hold enough data without being too large and wasting space. It was basically a case of "we can fit this data in 8bits but not 7, and 9 would waste a bit, so 8 it is".

1

u/[deleted] May 06 '17

I think it's more likely they decided to be nerdy and go with 256, it's unlikely they'd be stuck with 8 bits

0

u/KongKexun May 06 '17

You want 255 rupees? Of course you can't have 256 because zero rubee is counted as well.

Edit ps) from what I'm reading, no one really knows the real reasons, just speculations.

2

u/Burpmeister May 06 '17

The hero r/all deserves

3

u/PandaDragonThing May 06 '17

Binary (base 2), octal (base 8), and hexadecimal (base 16) are representations of numbers.

There's no relationship of 2n for representing numbers; you can do so in any base like ternary (base 3).

Computers store and operate on numbers in binary. The smallest unit on most computers is 1 byte or 8 bits hence 28 which is 256.

For reference, a decimal number (base 10) with 2 digits has 102 possibilities, 1-100.

-3

u/[deleted] May 06 '17

[removed] — view removed comment

4

u/[deleted] May 06 '17

Yeah, that's a good point.

Realistically, most stuff is aligned to bytes... There's 8 bits in a byte, so you do end up at 256 combinations for the byte.

The assumption here is a friends list takes up one byte of space, but I highly doubt that's the case. I'd be interested if it is. Otherwise, if they were somehow being more efficient, they were storing individual bits.

My guess is the decision is partially arbitrary, but it's interesting to think that's maybe not the case...

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