A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Sizik
Posts: 1224
Joined: Wed Aug 27, 2008 3:48 am UTC

### Re: Funniest/Most Annoying Code Comments

KnightExemplar wrote:
Triple Log wrote:OT: Hotaru, what does the code in your signature do? It doesn't even look standards-compliant.

It looks like it returns the factor of the number "n" under specific circumstances. If the heuristics don't play out, then it returns 0.

For example, "60" has a factor of 2 (and 3 and 5... but it returns 2 before 3 is returned). 77 returns 7, because its divisible by 7.

I'm unsure if the "add by digits" rule works for division by 3 in base-16... but that rule works in base-10.

Here's the full output:
Spoiler:
f(0) = 2
f(1) = 0
f(2) = 2
f(3) = 3
f(4) = 2
f(5) = 5
f(6) = 2
f(7) = 7
f(8) = 2
f(9) = 3
f(10) = 2
f(11) = 0
f(12) = 2
f(13) = 0
f(14) = 2
f(15) = 3
f(16) = 2
f(17) = 0
f(18) = 2
f(19) = 0
f(20) = 2
f(21) = 3
f(22) = 2
f(23) = 0
f(24) = 2
f(25) = 5
f(26) = 2
f(27) = 3
f(28) = 2
f(29) = 0
f(30) = 2
f(31) = 0
f(32) = 2
f(33) = 3
f(34) = 2
f(35) = 5
f(36) = 2
f(37) = 0
f(38) = 2
f(39) = 3
f(40) = 2
f(41) = 0
f(42) = 2
f(43) = 0
f(44) = 2
f(45) = 3
f(46) = 2
f(47) = 0
f(48) = 2
f(49) = 0
f(50) = 2
f(51) = 3
f(52) = 2
f(53) = 0
f(54) = 2
f(55) = 5
f(56) = 2
f(57) = 3
f(58) = 2
f(59) = 0
f(60) = 2
f(61) = 0
f(62) = 2
f(63) = 3
f(64) = 2
f(65) = 5
f(66) = 2
f(67) = 0
f(68) = 2
f(69) = 3
f(70) = 2
f(71) = 0
f(72) = 2
f(73) = 0
f(74) = 2
f(75) = 3
f(76) = 2
f(77) = 7
f(78) = 2
f(79) = 0
f(80) = 2
f(81) = 3
f(82) = 2
f(83) = 0
f(84) = 2
f(85) = 5
f(86) = 2
f(87) = 3
f(88) = 2
f(89) = 0
f(90) = 2
f(91) = 7
f(92) = 2
f(93) = 3
f(94) = 2
f(95) = 5
f(96) = 2
f(97) = 0
f(98) = 2
f(99) = 3
f(100) = 2
f(101) = 0
f(102) = 2
f(103) = 0
f(104) = 2
f(105) = 3
f(106) = 2
f(107) = 0
f(108) = 2
f(109) = 0
f(110) = 2
f(111) = 3
f(112) = 2
f(113) = 0
f(114) = 2
f(115) = 5
f(116) = 2
f(117) = 3
f(118) = 2
f(119) = 0
f(120) = 2
f(121) = 0
f(122) = 2
f(123) = 3
f(124) = 2
f(125) = 5
f(126) = 2
f(127) = 0
f(128) = 2
f(129) = 3
f(130) = 2
f(131) = 0
f(132) = 2
f(133) = 0
f(134) = 2
f(135) = 3
f(136) = 2
f(137) = 0
f(138) = 2
f(139) = 0
f(140) = 2
f(141) = 3
f(142) = 2
f(143) = 1
f(144) = 2
f(145) = 5
f(146) = 2
f(147) = 3
f(148) = 2
f(149) = 0
f(150) = 2
f(151) = 0
f(152) = 2
f(153) = 3
f(154) = 2
f(155) = 5
f(156) = 2
f(157) = 0
f(158) = 2
f(159) = 3
f(160) = 2
f(161) = 0
f(162) = 2
f(163) = 0
f(164) = 2
f(165) = 3
f(166) = 2
f(167) = 0
f(168) = 2
f(169) = 0
f(170) = 2
f(171) = 3
f(172) = 2
f(173) = 0
f(174) = 2
f(175) = 5
f(176) = 2
f(177) = 3
f(178) = 2
f(179) = 0
f(180) = 2
f(181) = 0
f(182) = 2
f(183) = 3
f(184) = 2
f(185) = 5
f(186) = 2
f(187) = 0
f(188) = 2
f(189) = 3
f(190) = 2
f(191) = 0
f(192) = 2
f(193) = 0
f(194) = 2
f(195) = 3
f(196) = 2
f(197) = 0
f(198) = 2
f(199) = 0
f(200) = 2
f(201) = 3
f(202) = 2
f(203) = 0
f(204) = 2
f(205) = 5
f(206) = 2
f(207) = 3
f(208) = 2
f(209) = 0
f(210) = 2
f(211) = 0
f(212) = 2
f(213) = 3
f(214) = 2
f(215) = 5
f(216) = 2
f(217) = 0
f(218) = 2
f(219) = 3
f(220) = 2
f(221) = 0
f(222) = 2
f(223) = 0
f(224) = 2
f(225) = 3
f(226) = 2
f(227) = 0
f(228) = 2
f(229) = 0
f(230) = 2
f(231) = 3
f(232) = 2
f(233) = 0
f(234) = 2
f(235) = 5
f(236) = 2
f(237) = 3
f(238) = 2
f(239) = 0
f(240) = 2
f(241) = 0
f(242) = 2
f(243) = 3
f(244) = 2
f(245) = 5
f(246) = 2
f(247) = 0
f(248) = 2
f(249) = 3
f(250) = 2
f(251) = 0
f(252) = 2
f(253) = 0
f(254) = 2
f(255) = 3
gmalivuk wrote:
King Author wrote:If space (rather, distance) is an illusion, it'd be possible for one meta-me to experience both body's sensory inputs.
Yes. And if wishes were horses, wishing wells would fill up very quickly with drowned horses.

Triple Log
Posts: 33
Joined: Thu Jul 17, 2014 5:32 pm UTC

### Re: Funniest/Most Annoying Code Comments

Sizik wrote:
KnightExemplar wrote:
Triple Log wrote:OT: Hotaru, what does the code in your signature do? It doesn't even look standards-compliant.

It looks like it returns the factor of the number "n" under specific circumstances. If the heuristics don't play out, then it returns 0.

For example, "60" has a factor of 2 (and 3 and 5... but it returns 2 before 3 is returned). 77 returns 7, because its divisible by 7.

I'm unsure if the "add by digits" rule works for division by 3 in base-16... but that rule works in base-10.

Here's the full output:
Spoiler:
f(0) = 2
f(1) = 0
f(2) = 2
f(3) = 3
f(4) = 2
f(5) = 5
f(6) = 2
f(7) = 7
f(8) = 2
f(9) = 3
f(10) = 2
f(11) = 0
f(12) = 2
f(13) = 0
f(14) = 2
f(15) = 3
f(16) = 2
f(17) = 0
f(18) = 2
f(19) = 0
f(20) = 2
f(21) = 3
f(22) = 2
f(23) = 0
f(24) = 2
f(25) = 5
f(26) = 2
f(27) = 3
f(28) = 2
f(29) = 0
f(30) = 2
f(31) = 0
f(32) = 2
f(33) = 3
f(34) = 2
f(35) = 5
f(36) = 2
f(37) = 0
f(38) = 2
f(39) = 3
f(40) = 2
f(41) = 0
f(42) = 2
f(43) = 0
f(44) = 2
f(45) = 3
f(46) = 2
f(47) = 0
f(48) = 2
f(49) = 0
f(50) = 2
f(51) = 3
f(52) = 2
f(53) = 0
f(54) = 2
f(55) = 5
f(56) = 2
f(57) = 3
f(58) = 2
f(59) = 0
f(60) = 2
f(61) = 0
f(62) = 2
f(63) = 3
f(64) = 2
f(65) = 5
f(66) = 2
f(67) = 0
f(68) = 2
f(69) = 3
f(70) = 2
f(71) = 0
f(72) = 2
f(73) = 0
f(74) = 2
f(75) = 3
f(76) = 2
f(77) = 7
f(78) = 2
f(79) = 0
f(80) = 2
f(81) = 3
f(82) = 2
f(83) = 0
f(84) = 2
f(85) = 5
f(86) = 2
f(87) = 3
f(88) = 2
f(89) = 0
f(90) = 2
f(91) = 7
f(92) = 2
f(93) = 3
f(94) = 2
f(95) = 5
f(96) = 2
f(97) = 0
f(98) = 2
f(99) = 3
f(100) = 2
f(101) = 0
f(102) = 2
f(103) = 0
f(104) = 2
f(105) = 3
f(106) = 2
f(107) = 0
f(108) = 2
f(109) = 0
f(110) = 2
f(111) = 3
f(112) = 2
f(113) = 0
f(114) = 2
f(115) = 5
f(116) = 2
f(117) = 3
f(118) = 2
f(119) = 0
f(120) = 2
f(121) = 0
f(122) = 2
f(123) = 3
f(124) = 2
f(125) = 5
f(126) = 2
f(127) = 0
f(128) = 2
f(129) = 3
f(130) = 2
f(131) = 0
f(132) = 2
f(133) = 0
f(134) = 2
f(135) = 3
f(136) = 2
f(137) = 0
f(138) = 2
f(139) = 0
f(140) = 2
f(141) = 3
f(142) = 2
f(143) = 1
f(144) = 2
f(145) = 5
f(146) = 2
f(147) = 3
f(148) = 2
f(149) = 0
f(150) = 2
f(151) = 0
f(152) = 2
f(153) = 3
f(154) = 2
f(155) = 5
f(156) = 2
f(157) = 0
f(158) = 2
f(159) = 3
f(160) = 2
f(161) = 0
f(162) = 2
f(163) = 0
f(164) = 2
f(165) = 3
f(166) = 2
f(167) = 0
f(168) = 2
f(169) = 0
f(170) = 2
f(171) = 3
f(172) = 2
f(173) = 0
f(174) = 2
f(175) = 5
f(176) = 2
f(177) = 3
f(178) = 2
f(179) = 0
f(180) = 2
f(181) = 0
f(182) = 2
f(183) = 3
f(184) = 2
f(185) = 5
f(186) = 2
f(187) = 0
f(188) = 2
f(189) = 3
f(190) = 2
f(191) = 0
f(192) = 2
f(193) = 0
f(194) = 2
f(195) = 3
f(196) = 2
f(197) = 0
f(198) = 2
f(199) = 0
f(200) = 2
f(201) = 3
f(202) = 2
f(203) = 0
f(204) = 2
f(205) = 5
f(206) = 2
f(207) = 3
f(208) = 2
f(209) = 0
f(210) = 2
f(211) = 0
f(212) = 2
f(213) = 3
f(214) = 2
f(215) = 5
f(216) = 2
f(217) = 0
f(218) = 2
f(219) = 3
f(220) = 2
f(221) = 0
f(222) = 2
f(223) = 0
f(224) = 2
f(225) = 3
f(226) = 2
f(227) = 0
f(228) = 2
f(229) = 0
f(230) = 2
f(231) = 3
f(232) = 2
f(233) = 0
f(234) = 2
f(235) = 5
f(236) = 2
f(237) = 3
f(238) = 2
f(239) = 0
f(240) = 2
f(241) = 0
f(242) = 2
f(243) = 3
f(244) = 2
f(245) = 5
f(246) = 2
f(247) = 0
f(248) = 2
f(249) = 3
f(250) = 2
f(251) = 0
f(252) = 2
f(253) = 0
f(254) = 2
f(255) = 3

Well, hey, thanks for that information. Looks like some useless code (or at least convoluted beyond repair), but cool nonetheless.

Maybe it would have a place in the "Hacks and Snippets" thread?

phlip
Restorer of Worlds
Posts: 7557
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

### Re: Funniest/Most Annoying Code Comments

KnightExemplar wrote:I'm unsure if the "add by digits" rule works for division by 3 in base-16... but that rule works in base-10.

The add-the-digits trick in base b works for division by (b-1), or any factor thereof. So, in decimal, it works for division by 3 or 9... in hex it works for division by 3, 5 or 15. You could also theoretically do another add-the-digits step in octal to check divisibility by 7.

Code: Select all

`enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}`
[he/him/his]

Sizik
Posts: 1224
Joined: Wed Aug 27, 2008 3:48 am UTC

### Re: Funniest/Most Annoying Code Comments

Triple Log wrote:OT: Hotaru, what does the code in your signature do? It doesn't even look standards-compliant.

Just curious, what makes you think it's not standards compliant?
gmalivuk wrote:
King Author wrote:If space (rather, distance) is an illusion, it'd be possible for one meta-me to experience both body's sensory inputs.
Yes. And if wishes were horses, wishing wells would fill up very quickly with drowned horses.

Triple Log
Posts: 33
Joined: Thu Jul 17, 2014 5:32 pm UTC

### Re: Funniest/Most Annoying Code Comments

Sizik wrote:
Triple Log wrote:OT: Hotaru, what does the code in your signature do? It doesn't even look standards-compliant.

Just curious, what makes you think it's not standards compliant?

I don't know what the following operator does and have never seen it:

Code: Select all

`&=`

Is that even a thing?
Along with adding bitwise operations and multiple ternary statements in one.

Though I will admit, the multiple ternary statements is pretty cool.

Xenomortis
Not actually a special flower.
Posts: 1426
Joined: Thu Oct 11, 2012 8:47 am UTC

### Re: Funniest/Most Annoying Code Comments

It's like +=, -=, etc.
& is "binary and" - it performs a bitwise and on the two arguments.

Code: Select all

`x = 0xF3 //(= 11110011)y = 0xA5 //(= 10100101)return x & y`

will return 0xA1 (=10100101)

So x &= y is the same as x = x & y.

You do have to be quite careful in C, when chaining multiple operations together.
The order they're resolved is not necessarily defined.

Triple Log
Posts: 33
Joined: Thu Jul 17, 2014 5:32 pm UTC

### Re: Funniest/Most Annoying Code Comments

Xenomortis wrote:It's like +=, -=, etc.
& is "binary and" - it performs a bitwise and on the two arguments.

Code: Select all

`x = 0xF3 //(= 11110011)y = 0xA5 //(= 10100101)return x & y`

will return 0xA1 (=10100101)

So x &= y is the same as x = x & y.

You do have to be quite careful in C, when chaining multiple operations together.
The order they're resolved is not necessarily defined.

I don't quite see how binary and works. Is there any use for it?

KnightExemplar
Posts: 5494
Joined: Sun Dec 26, 2010 1:58 pm UTC

### Re: Funniest/Most Annoying Code Comments

Triple Log wrote:I don't quite see how binary and works. Is there any use for it?

Binary forms the basis of all computer calculations. Nearly everything calculated on a modern computer is done in binary, before being translated into your normal "decimal" notation. (There were older computers that performed calculations on decimal numbers, and there is the "adc" instructions in x86 Assembly to support decimal addition. But these are edge cases that defy the norm.)

Negative numbers are represented as Binary numbers with a leading 1, in so called '2's complement' notation. Understanding this will give you full understanding of how addition and subtraction work on computers.

Don't worry about it for now if you're a beginner, but know that deep understanding of computer arithmetic requires you to understand binary. Modern programming languages allow you to mostly work in decimal and forget the details... but every now and then (ie: Overflow, underflow), binary rears its ugly head and you've got to think about weird cases due to the translations that happen between binary and everything else.
First Strike +1/+1 and Indestructible.

Xenomortis
Not actually a special flower.
Posts: 1426
Joined: Thu Oct 11, 2012 8:47 am UTC

### Re: Funniest/Most Annoying Code Comments

There are four "basic" or important binary operations; AND, OR, XOR and NOT.
Fundamentally, these really operate on a single bit.
A AND B is True if and only if both A and B are True.
A OR B is True if and only if at least one of A and B are True.
A XOR B is True if and only if A and B are different (precisely one is True).
NOT A is True if A is False and vice versa.

When we come to deal with computers, we operate on bytes, words, dwords, etc.
The bitwise operations apply their operation to each bit-pair of the operands.

e.g.
A = a1a2a3a4
B = b1b2b3b4

Then A & B = (a1 AND b1), (a2 AND b2), (a3 AND b3), (a4 AND b4)

Going back to the previous example:

Code: Select all

`x = 0xF3 //(= 11110011)y = 0xA5 //(= 10100101)x & y = 0xA1 (= 10100001)`

Starting from the right-most bit (least significant bit, or the "zeroth" bit), we see that it's 1 for both x and y, so the zeroth bit for x&y is 0.
For the next bit, we see it's 0 for y, so x&y's next bit must be 0. Similarly, the next two must be 0 since one is 0 for x and the one after is 0 for y.
We can see the top four bits of x are all 1, so the top bits of x&y are going to be whatever the top four bits of y are.

Code: Select all

`x =       1 1 1 1 0 0 1 1y =       1 0 1 0 0 1 0 1x & y =   1 0 1 0 0 0 0 1`

As for practical use?
Well AND is often used for masking; i.e "ignoring" part of a number.
So suppose I have some 32 bit integer and I'm only interested in the low word (the least significant 16 bits), then I simply mask the most significant 16 bits away.

Code: Select all

`int x = 231512351; //I want the bottom 16 bitsint y = x & 0x0000FFFF //in hexadecimal, an F means "four on bits and no off bits"//y = 39199 = 0x991F`

This might come up if I'm reading data from a file using a binary file format (non-text); whether a particular bit is on or not in some byte can carry meaning.

XOR is often used to "flip" bits
For instance, in ASCII, upper case letters occupy the range 0x41 - 0x5A (65 to 91) whilst lower case letters are in the range 0x61-0x7A (97-122).
i.e. the difference between 'A' and 'a' is 32 (0x20) - with 'A', the 5th bit is off, with 'a' it's on.
So I can convert an upper case character to a lower case character and vice versa simply by inverting that bit.

Code: Select all

`char x = 'a';char y = x ^ 32;//x = 'A';`

OR is used to force particular bits on; often when merging flags or building up numbers from individual bits or bytes (although it's often equivalent to simple addition).

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Contact:

### Re: Funniest/Most Annoying Code Comments

I'd say & is most commonly useful for bit flags. Suppose that you have several related Boolean settings, for example for controlling different things that could be output, and that all (or at least most) combinations are valid. You could have separate variables for each setting, e.g.

Code: Select all

`bool print_thing1 = ...;bool print_thing2 = ...;bool print_thing3 = ...;bool print_thing4 = ...;...if (print_thing1)    print(thing1);if (print_thing2)    print(thing2);if (print_thing3)    print(thing_3);if (print_thing4)    print(thing_4);`
but it is sometimes more convenient (sometimes much more convenient) to use a bitfield:

Code: Select all

`const unsigned int PRINT_THING1 = 0x1; // 0001const unsigned int PRINT_THING2 = 0x2; // 0010const unsigned int PRINT_THING3 = 0x4; // 0100const unsigned int PRINT_THING4 = 0x8; // 1000unsigned int print_flags = ...;...if (print_flags & PRINT_THING1)    print(thing1);if (print_flags & PRINT_THING2)    print(thing2);if (print_flags & PRINT_THING3)    print(thing3);if (print_flags & PRINT_THING4)    print(thing4);`
This may not seem so convincing, but even now we already have just a single variable that you have to pass around from function to function or whatever instead of four. But it can get even more convenient, because you can do things like define PRINT_COMMON = PRINT_THING1 | PRINT_THING2, which sets PRINT_COMMON to 3, aka 0011 binary. And now if you want the most common flag settings, you just say print_flags = PRINT_COMMON instead of print_thing1 = true; print_thing2 = true; print_thing3 = false; print_thing4 = false;. There are other sort of "bulk" operations you can do on all the flags at once as well, instead of having to individually adjust several variables.

This idea can be extended. You can view it as using each bit as a Boolean yes/no value, but you can use several bits for a really small integer. For example, for a while an encoding of numbers called "binary-coded decimal" (BCD) was used.* Normally, a number like 25 would be encoded as the binary value 00011001 (16+8+1). BCD looks at each digit of the decimal expansion -- 25 -- and uses 4 bits (the lowest number that can represent all numbers 0-9) for each digit. 25 would be encoded as [0010][0101], where 0010b=2 and 0101b=5 (4+1). Conveniently, 4bits + 4bits = 8bits = 1byte, which means you could store two digits per byte. If you wanted to do something with those digits, you'd have to extract them somehow... and for that you'd use &. For example, suppose I wanted to print out a single-byte BCD number:

Code: Select all

`unsigned char  byte = 25; // or whateverunsigned char first_digit = (byte & 0xF0) >> 4;  // 0xF0 = [1111][0000] binaryunsigned char second_digit = byte & 0x0F; // 0x0F = [0000][1111] binary`
The >> is a right shift; >>4 moves every bit four spaces to the right. The four rightmost digits drop off, and the four leftmost digits are filled with 0s. (Actually because the rightmost digits are discarded anyway, you don't really need the & for first_digit... but I put it in there anyway for explanatory reasons.)

(* Just a note: I don't mean to imply that BCD was the only thing around or even close to the most popular thing, just that you saw it sometimes. It was popular enough that x86 actually includes several instructions for assisting with BCD operations. (E.g. you can't add BCD numbers with just a typical add instruction, because you'd wind up with things like 77 + 77 = (14)(14) (0111 0111 + 0111 0111 = 1110 1110) where each (14) is a single "digit". And hey, you'd have invented hex, except you started with BCD. )

So for 25, we have:

Code: Select all

`byte = [0010][0101]byte & 0xF0 = ([0010][0101] & [1111][0000]) >> 4 = [0010][0000] >> 4 = [0000][0010], which if you drop [] and interpret as a straight binary number, is 2byte & 0x0F = [0010][0101] & [0000][1111] = [0000][0101], which if you drop [] and interpret as a straight binary number, is 5`

This sort of thing comes up in some network protocols and file formats and stuff, when people feel (rightly or wrongly) that they "have to" optimize for space.
Last edited by EvanED on Thu Jul 31, 2014 6:17 pm UTC, edited 1 time in total.

Triple Log
Posts: 33
Joined: Thu Jul 17, 2014 5:32 pm UTC

### Re: Funniest/Most Annoying Code Comments

Thank you for the explanations. I think I ind of grasp it, but won't be using it for a long time so it's not a major concern.

A truth table would have been a nice way to explain it, too.

ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

### Re: Funniest/Most Annoying Code Comments

Xenomortis wrote:There are four "basic" or important binary operations; AND, OR, XOR and NOT

Or, if you prefer, one (NAND).
He/Him/His/Alex
God damn these electric sex pants!

Xenomortis
Not actually a special flower.
Posts: 1426
Joined: Thu Oct 11, 2012 8:47 am UTC

### Re: Funniest/Most Annoying Code Comments

ahammel wrote:
Xenomortis wrote:There are four "basic" or important binary operations; AND, OR, XOR and NOT

Or, if you prefer, one (NAND).

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

### Re: Funniest/Most Annoying Code Comments

KnightExemplar wrote:
Triple Log wrote:I don't quite see how binary and works. Is there any use for it?

Binary forms the basis of all computer calculations. Nearly everything calculated on a modern computer is done in binary, before being translated into your normal "decimal" notation. (There were older computers that performed calculations on decimal numbers, and there is the "adc" instructions in x86 Assembly to support decimal addition. But these are edge cases that defy the norm.)

In what way is adc related to decimal addition? It most frequent use is implementing multi-word additions. You probably mean the AA* instructions that operate on BCDs.

Archgeek
Posts: 205
Joined: Wed May 02, 2007 6:00 am UTC
Location: Central US
Contact:

### Re: Funniest/Most Annoying Code Comments

Ack, this hilarious thread filled with sigbait is drying up? I refuse to accept that! So here's some of my own Thomas Foolery:

On a CSS trick for triangular arrows--

Code: Select all

`/*Blackest Sorcery: arrows are conjured from the aether by using the interior-facing bordersof a zero-hight block with the thickness of the identical upper and lower borders to pinch them down to triangles*/`

Later in the same CSS file--

Code: Select all

`/*Another type of Sorcerer's Arrow: tool-tip style arrows are conjured from the aether by using the interior-facing borders of an empty with the thickness of the identical side  borders to pinch them down to triangles.  Height is determined by the top attribute, the bottom border provides the colour, and the larger "before" triangle serves as a border to the smaller "after" triangle.*/`

In function translating file sizes to human-readable format--

Code: Select all

`//fails with files larger than 2^90 bytes`

...and then there's this thing:

Code: Select all

`if(DEBUG_MODE){   txt += "<br>" + i + ": " + file.name + "<br>";   txt += "_  size: " + formatFileSize(/*lolhax42*/file.size) +"<br>";// #lolhax<br>";   txt += "_  type: " + file.type/*lolhax*//*"fish/trout"*/ + "<br>";`
bearing strange artifacts of testing.
"That big tube down the side was officially called a "systems tunnel", which is aerospace contractor speak for "big tube down the side."

scarecrovv
It's pronounced 'double u'
Posts: 674
Joined: Wed Jul 30, 2008 4:09 pm UTC
Location: California

### Re: Funniest/Most Annoying Code Comments

Today I saw this:

Code: Select all

`#define private public`

This was annotated with two comments, one a severe reprimand, and the other an apology.

Xeio
Friends, Faidites, Countrymen
Posts: 5099
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

### Re: Funniest/Most Annoying Code Comments

Archgeek wrote:In function translating file sizes to human-readable format--

Code: Select all

`//fails with files larger than 2^90 bytes`
Hah, just wait till I get that brontobyte hard drive.

hotaru
Posts: 1042
Joined: Fri Apr 13, 2007 6:54 pm UTC

### Re: Funniest/Most Annoying Code Comments

Xeio wrote:
Archgeek wrote:In function translating file sizes to human-readable format--

Code: Select all

`//fails with files larger than 2^90 bytes`
Hah, just wait till I get that brontobyte hard drive.

they really ought to have made it work all the way up to 2396 bytes. I'll be really surprised if anyone actually realizes what I did there...
Last edited by hotaru on Tue Oct 21, 2014 9:55 pm UTC, edited 2 times in total.

Code: Select all

`factorial = product . enumFromTo 1isPrime n = factorial (n - 1) `mod` n == n - 1`

Derek
Posts: 2179
Joined: Wed Aug 18, 2010 4:15 am UTC

### Re: Funniest/Most Annoying Code Comments

scarecrovv wrote:Today I saw this:

Code: Select all

`#define private public`

This was annotated with two comments, one a severe reprimand, and the other an apology.

Reminds me of the classic joke:

Code: Select all

`#define while if   //Speed optimization`

And the corresponding,

Code: Select all

`#define int char   //Space saving optimization`

You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

### Re: Funniest/Most Annoying Code Comments

Derek wrote:
scarecrovv wrote:Today I saw this:

Code: Select all

`#define private public`

This was annotated with two comments, one a severe reprimand, and the other an apology.

Reminds me of the classic joke:

Code: Select all

`#define while if   //Speed optimization`

And the corresponding,

Code: Select all

`#define int char   //Space saving optimization`

I propose the following optimizations

Code: Select all

`#define malloc(x) malloc(x - 1); #define free(x) realloc(x, 1); `
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

### Re: Funniest/Most Annoying Code Comments

I don't think realloc is cheaper than free But hey this eliminates fragmentation!

You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

### Re: Funniest/Most Annoying Code Comments

Oh, no, the free optimization is a safety measure. You don't have to worry about dereferencing a pointer after free()
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

phlip
Restorer of Worlds
Posts: 7557
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

### Re: Funniest/Most Annoying Code Comments

You still do, though... unless you make it something like

Code: Select all

`#define free(x) (x = realloc(x, 1))`
which obviously couldn't have any I'll effects...

Code: Select all

`enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}`
[he/him/his]

### Who is online

Users browsing this forum: No registered users and 6 guests