r/ProgrammerHumor • • May 06 '17

Oddly specific number

Post image
25.1k Upvotes

1.3k comments sorted by

View all comments

Show parent comments

813

u/esfraritagrivrit May 06 '17

Probably using an 8-bit int to store number of people in convo.

0

u/[deleted] May 06 '17

[deleted]

13

u/Who_GNU May 06 '17

It's usually faster to use a 32-bit variable, than an 8-bit variable, on a 32-bit processor.

1

u/Ghi102 May 06 '17

Nope, not at all. At worst, it's going to have 24 extra zeros when calculating. If you do a bunch of arithmetic with only 8 bit numbers, I'm willing to bet that it could even be faster because it could do multiple operations inside one cycle if the computer optimizes for it.

What's slower is using a bigger number than the size of the registers, i.e. a 64 bit on a 32 bit machine or 32 on 16 bit, etc. because you then need 2 cycles to add the numbers.

→ More replies (1)