Skip to main content

Timeline for Longest code to add two numbers

Current License: CC BY-SA 3.0

25 events
when toggle format what by license comment
Mar 14, 2014 at 23:42 comment added Comintern @Kninnug - If you generate the code with the same compiler, it will give the same undefined result as the original additions would have.
Mar 14, 2014 at 23:30 comment added Kninnug I thought the behaviour for overflow on signed integers was undefined. How exactly is it 'preserved' (i.e: what behaviour does it actually exhibit on overflow?)
Mar 10, 2014 at 8:24 comment added phresnel For long long there would be 3.4028237e+38 if-statements, or (hopefully I shifted the dot correctly) 340282370000000000000000000000000000000, assuming an average of 50 bytes per if-statement, this would be 1.5845633e+31 GiB, or 15845633000000000000000000000000 GiB, which is 140737490000000000 Yobibyte, I think.
Mar 7, 2014 at 13:29 comment added Twinkles I can try as soon as my 3 Zettabyte harddisk arrives. Don't hold your breath, though...
Mar 7, 2014 at 13:06 comment added Chuu Did anyone benchmark this compared to operator+? I'm incredibly curious.
Mar 7, 2014 at 10:12 comment added Mr Lister But this does not conform to the rules of the question. The question doesn't say integers only. This code should be much longer!
Mar 7, 2014 at 2:46 comment added ɲeuroburɳ You could add a few billion characters by using octal (2147483648 => 020000000000) and hex (0 => 0x0) as (in-)apprioriate.
Mar 6, 2014 at 22:29 comment added bolov Has anybody noticed that the program to add ints has a size not representable with ints
Mar 6, 2014 at 20:08 comment added Comintern @nneonneo Umm.... it's still compiling? :-)
Mar 6, 2014 at 19:44 comment added nneonneo Objection, on the grounds that you clearly haven't tested the code. (And no, I'm not about to test this for you).
Mar 6, 2014 at 12:40 comment added 8bitwide @Radiodef, I love your suggestion because it not only would make the code long but also "better" written. Of course, he could go full retard and do switch statements in switch statements
Mar 6, 2014 at 11:19 comment added PlasmaHH You should have used int64_t and input by string using atol() in each statement.
Mar 5, 2014 at 14:55 comment added Comintern @JasonC OK, the named constant idea made me laugh. Even more "descriptive" would be #define LEFT_SIDE_NEG_TWO_ONE_FOUR_SEVEN_FOUR_EIGHT_THREE_SIX_FOUR_EIGHT = -2147483648 The only problem with adding more characters is that I'd have to figure out the count again...
Mar 5, 2014 at 11:27 comment added devnull Did they pay you per character? You reduced your pay significantly by using short-circuiting.
Mar 5, 2014 at 8:51 comment added Pieter Witvoet Did they pay you per line of code?
Mar 5, 2014 at 8:36 comment added VisioN ... and wrap return X; with brackets: { return X; } or use longer variable names instead of x and y.
Mar 5, 2014 at 6:17 comment added Jason C You could also define separate named constants for each of the integers (LEFT_SIDE_NEG_2147483648 = -2147483648)... it's good practice to use descriptive names instead of hard-coded values, you know.
Mar 5, 2014 at 6:04 comment added Radiodef You know you could make this longer if you use else if.
Mar 5, 2014 at 4:19 comment added Comintern @Izkata - Yep, and it's all fun and games until the tester says "Great! We passed the addition tests. Now for the subtraction tests...".
Mar 5, 2014 at 4:09 comment added Izkata Whenever someone describes test-driven development as "do the minimum thing to make the new test pass", this type of code always pops into mind...
Mar 5, 2014 at 2:55 history edited Comintern CC BY-SA 3.0
Calculated exact score.
Mar 5, 2014 at 2:29 comment added Dennis You had me at snippet of the code.
Mar 5, 2014 at 2:14 history edited Comintern CC BY-SA 3.0
Recalculate score
Mar 5, 2014 at 2:07 history edited Comintern CC BY-SA 3.0
Copy-paste errors
Mar 5, 2014 at 2:01 history answered Comintern CC BY-SA 3.0