Happy Halloween! Or, if you're a programmer, merry Christmas! 🎃🎄 Do you understand this joke?
Link to tweet
I'm not a programmer, so I don't get the joke. Can someone explain it, please ? Thanks and Happy Halloween/Samhain
AJT
(5,240 posts)Fresh_Start
(11,342 posts)nt
rurallib
(63,254 posts)3 (8s) = 24 + 1 (single) = 25
dragonlady
(3,577 posts)Decimal 25 = Octal 31 (8x3=24, + 1=25)
krispos42
(49,445 posts)A programmer finished up at work for the day and calls his wife to see if she wants him to pick anything up on the way home. She says "Stop by the store and pick up a gallon of milk. If they have eggs, get a dozen."
He went home with 12 gallons of milk.
i guess they had eggs
when she gets upset, does he dare to tell her she needs to write better specs?
magicarpet
(16,747 posts)Why do programmers always mix up Halloween and Christmas? Because Oct 31 = Dec 25.
The joke here is that Octal 31 (which abbreviated looks like October 31st, Halloween) is equal to Decimal 25 (which abbreviated looks like December 25th, Christmas).
Decimal and octal are two number systems with different bases.
Decimal is the base-10 number system that everyone is familiar with. A number system has as many digits as its base number. That means a base-10 number system 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) and is where it gets its name from (decimal, from Latin decimus, means tenth).
When you get to a number that is higher than the highest digit, you add another column to the left, so you count like 8, 9, 10, 11, 12, and so on.
Octal (from the Latin root oct- meaning eight) is a base-8 number system commonly used in programming. A base-8 system means it has 8 digits (0, 1, 2, 3, 4, 5, 6, and 7). When you get to a number higher than 7, you also add another column, so you count like 6, 7, 10, 11, 12, and so on.
If we convert the octal 31 to decimal, we end up with 25. Watch: if we break octal 31 out to a math equation, it ends up being 3 x 81 + 1 x 80 = 3 x 8 + 1 x 1 = 24 + 1 = decimal 25.
To convert the other way, you start with the biggest power of the base (8, in this case) you can divide by and get a whole number, then take that and divide the remainder by the next smaller power until you get to the 0-th power. Then you just combine the digits together. In the case of 25, we need to start at 81: 25 / 81 = 3, remainder of 1 / 80 = 1, so 31.