### Write a program that makes 2 + 2 = 5

• Write a program that seemingly adds the numbers 2 and 2 and outputs 5. This is an underhanded contest.

Your program cannot output any errors. Watch out for memory holes! Input is optional.

Redefining 2+2 as 5 is not very creative! Don't doublethink it, try something else.

This is question in book "1984" by George Orwelll.

Why is this underhanded? Two plus two *is* five.

THERE! ARE! FOUR! LIGHTS!

@Geobits - I agree: 2+2=5 you can see it in this calculator.

`echo "2+2=5";`

I always thought that `2 + 2 = 5` for very large values of 2.

`(1<<2)+(2>>1)`

Big Brother? NOT ROOM 101 :(

Python: >>> 1 + 2e-60 + 2e-60 == 1+ 5e-60 True

To see discussions of this question and its answers: Reddit and Hacker News.

C/C++ `char flush[] = "\n \003"; printf("%d\n", 2 + 2 [flush]);`

#include int main(int argc, char** argv) { char c = '2'; int a = (int)c; printf("%c+%c=%d\n", c, c, a/10)); return 0; }

(function () { var two = 2; console.log(two+++two); })();

@MT0 I thought you were referring to this 100% accurate model

Not enough reputation for a post, so C# alternative is here: `int x = 2, y = 2;` `Action action = () => Console.WriteLine(x + y);` `x++;` `action();`. Not working in .Net 4.5+

@MichaelT I can't believe my question made it to reddit, haha

`int i = 2 + 2; Console.Write(++i);` C#

The teacher Jonofon Serates shows an way to do it mathematically https://www.youtube.com/watch?v=xanIFMTxKGs it is in Portuguese, anyway the math is the same in any language :D

Drat. I have a really short FORTRAN answer that *actually happened to me once*, but not enough reputation to add it.

Sadly, I don't have enough reputation to post, but I really wanted to post something. First off, this is probably invalid ;-; but here's my Brainf*** code, which sizes in at 63 bytes: `++++[>++++[>+++<-]<-]>>++.-------.+++++++.+++++++++++.--------.`

I'm closing this question in compliance with our policy on underhanded challenges.

• ## Java

Reflection is indeed the right way to go with abusing Java... but you need to go deeper than just tweaking some values.

``````import java.lang.reflect.Field;

public class Main {
public static void main(String[] args) throws Exception {
Class cache = Integer.class.getDeclaredClasses()[0];
Field c = cache.getDeclaredField("cache");
c.setAccessible(true);
Integer[] array = (Integer[]) c.get(cache);
array[132] = array[133];

System.out.printf("%d",2 + 2);
}
}
``````

Output:

``````5
``````

Explanation:

You need to change it even deeper than you can typically access. Note that this is designed for Java 6 with no funky parameters passed in on the JVM that would otherwise change the IntegerCache.

Deep within the Integer class is a Flyweight of Integers. This is an array of Integers from −128 to +127. `cache[132]` is the spot where 4 would normally be. Set it to 5.

Warning: Doing this in real code will make people very unhappy.

Thought of this one as soon as I saw the question :)

That. Is. Evil. Absolutely evil. +1

@JanDvorak in chat it was suggested `Integer[] array = (Integer[]) c.get(cache); fisherYatesShuffle(array);` Just imagine how many things would break...

@MichaelT this got me thinking about a new kind of russian roulette ;-)

Since you're already using reflection, you could easily make this independent of the cache size (which does depend on runtime flags after all): `Field f = Integer.class.getDeclaredField("value"); f.setAccessible(true); f.set(4, 5)` Could be made even more reliable by just grabbing the first non-static field - any reasonable implementation will only have a single field after all.

Answers like this make me love this site more than SO.

@Voo true, and I did consider that a bit. However, its not quite as subtle/underhanded... the code above doesn't even use the digits 4 or 5.

@Michael Fair point, considering the goal of making it underhanded. So right you are, way less obvious this way

@MichaelT `Collections.shuffle(Arrays.asList(array));`

To make this underhanded, the manipulation has to be hidden a bit more.

@MichaelT I'm new to Java, can you explain why this ability exists at all? Seems dangerous to leave in a language.

@qwr reflection belongs to a type of programming known as metaprograming - writing programs *about* structures within the language. That type of thing exists in many languages and is a key part of how some things are done. You can see similar things in python and can be used to do some really neat things but that comes at the cost of being able to do dangerous stuff.

@qwr as an aside, I'm frequently in The Whiteboard chat room of Programmers.SE and would be more than happy to go through some of the uses of metaprogramming in Java (there are really *neat* things you can do with it if you use a 'safer' approach of annotations with libraries that understand them (rather than just poking around in the innards of a class)).

It is very sad that one can do this.

evil.js, evil.sh, evil.css and **evil.java**

@SebastianGodelet there are a number of design choices that facilitate this, all for very good reasons. Metaprogramming that allows for advanced debuggers, introspection, and libraries. A Flyweight pattern in the Integer for performance when boxing and reduce memory usage. And a varargs structure allowing for variable length parameter lists (but then must be Objects rather than primitives). This combination of design choices can allow someone to poke in places they shouldn't but also allows for much more powerful programs and libraries.

I just love Java's reflection. Way more freedom than .NET world.

Anyone intending to do this should make sure to only have this happen a small fraction of the time. And then make sure to add a check in front of one of your statements something like "if 2+2= 5 then" with some comment about "for some reason sometimes 2+2=5, this accounts for these situations" so anyone reading it in the future is confused even more.

zomg, java answers never get top votes! +1 for bringing java to the top :)

@enderland The dailyWTF munger program does just that, constantly reconfigures `Integer`s

There are other Java reflection tricks, like changing immutable strings. The internal functionality of the String class has changed slightly over the years, but this should still be possible.

@JohnGaughan there was an answer that did that though I can't seem to find it (I thought it was a good one) and exposes some interesting bits on how String interning worked and where things where done when. That said, I'm still quite pleased with this approach because of its lack of use of the numbers `4` and `5` in the code.

With this, any calculation that would normally result in 4 will result in 5 correct? `1 + 3 = 5`, `4 * 1 = 5`, `2 * 2 = 5`, `9 - 5 = 5`...

@Mr.Mindor when cast to an Integer either with autoboxing or `valueOf()` - yes. I change the value of the entry where `4` sits in the IntegerCache class to be the same as `5` and anything that uses that will have the value of 5.

Changing the value of a constant? Java emulating old FORTRAN! This is the final proof that real programmers can write FORTRAN in any language ;-)

So, sometimes Java lets you do crazier things than you could do in LISP...

Interestingly, `printf("%d",2+2)` prints 5, but `System.out.println(2+2)` prints 4. Can anyone offer any insight into what's going on there?

@DavisYoshida printf(String format, Object... args)) takes an `Object` array while println(int x)) takes an int. Thus, the value returned by `2+2` must be cast to an Object (an Integer in this case) by being auto boxed using `valueOf(2+2)`. Look at valueOf and the cache.

@Cruncher so you are giving votes because he is _receiving_ votes? When does it end?

@Cyoce When there's noone else to vote? And other people that don't share my sentiment? lol. I do only count for one vote ya know ;)

I just love how you can throw anything at ghci and it totally rolls with it.

``````λ> let 2+2=5 in 2+2
5
``````

What does `let 2+2=5 in 5+5` do? ಠ_ಠ

Define function named `2+2` that return `5`

@JanDvorak `Non-exhaustive patterns in function +` - I'm defining a new function (+) here, and If I plug in anything that isn't `2+2` it will error because I never defined what should happen in that case.

@Flonk I got it. That's why I used my look of disapproval ;-)

@JanDvorak haha, okay ಠ_ಠ

The plus operator is a function, and `let` can redefine existing functions. `let (+) 2 2 = 5 in (+) 2 2`

that almost sounds like: "And God said let 2+2=5 in 2+2" ))

@N0ir unfortunately, Genesis doesn't make for a valid Haskell code. Not even the first chapter. Not even the verse you mention.

I'm a fan of the `where` version: `2 + 2 where 2 + 2 = 5`. It even pops up on t-shirts! It doesn't work in GHCi though :(.

`let 2+2=5; x+y= x Prelude.+ y in 5+5` only redefines 2+2 and leaves the rest of addition alone.

How does this even work? How is this actually allowed?!

@Jefffrey Thanks for your condescending comment, but I am actually well-versed in Haskell. I just have never seen this pattern before.

@user3217013 You are just defining the function (+) using equational style, where you define what should happen when the first argument is 2 and the second is 2, and you don't define all the other cases (thus, an inexhaustive definition). Kind of `case (x, y) of (2, 2) -> 5`

@user3217013 A `let` expression in Haskell defines a local variable to a specified value within the context of that expression. But "variable" here in fact encompasses not just things like `x` and `y`, but also infix operators like `+`, and values encompass not just things like `5` or `"Hello World!"`, but also functions. When an expression is evaluated in Haskell, the variables' values are looked up in the nearest defining scope. So in this example, `+` is redefined, in the scope of this expression only, to a function that produces `5` when both arguments are `2`.

I don't see why this gets so many votes. It doesn't make it appear that adding 2 + 2 gives the answer 5 at all. It's too explicit - big bzzzzzt!

It is rather too explicit. Better would be to redefine it in one place, and have the call in another, further down the stack. It isn't possible to compile a Haskell program with a modified version of the Haskell prelude, is it?

@JanDvorak Damn it, I always get that part wrong.

• ## C

Pretty cheap trick but I'm sure I will trap the most of you.

``````int main() {
int a = 2 + 2;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     a++;
printf("%d",a);
return 0;
}
``````

Try it here

Scroll the code to the right.
I'm not sure on Windows/Linux but on OSX, the scrollbar is not visible.
Anyway, this is a good reason to enable "space visualization" on your favorite code editor.

Scrollbar is visible in Chromium, but who pays attention to it at first? :)

To confuse folks, you might add a comment line that is long enough to "explain" the existence of a scrollbar, but dull enough so that noone cares to (scroll in order to) read it.

Well, I had spotted the scrollbar (in Firefox).

In OS X, scrollbar visibility by default depends on whether a mouse is connected. If there's just a touchpad, scrollbars are overlaid and fade out when not in use. If there's a mouse connected, scrollbars steal space from the context box and are always visible. You can test this by unplugging and plugging in a USB mouse to a MacBook. This can be configured in System Preferences, of course.

Clever, but on mobile it just wordwraps :)

This is the only time that scrolling SE code windows *don't* make me want to break someone's fingers.

Rather than space-visualization, get an IDE which properly formats code. That will fix not just this problem, but a host of others.

This is how i passed my remake 'malloc' assignment

@Ruslan Me? Now *that* is evil.

@AnonymousPi you must have intended to address not me...

@Ruslan No, I meant that I noticed the scrollbar and that Michael's post was evil because it seems that few people noticed it...

@Logan not for me in the Stack Exchange Android app (Nexus 5).

That got me ahahaha! Check out my C answer, love seeing C used on CodeGolf :D http://codegolf.stackexchange.com/a/59591/16513

You got me. This trick will be much fun if someone designs an editor that allows colouring the letters and setting a camera on programmers while they debug the code.

When you click "Run it here" and then "Run" it wordwraps.

• ## GolfScript

``````4:echo(2+2);
``````

Prints `5`.

Of course GolfScript has a syntax that is markedly different from other languages, this program just happen to look like something Basic or C-ish.

`4  ` - Put the number 4 on the stack. Stack content: 4
`:echo` - Save the value at the top of the stack to the variable echo. Stack content: 4
`(  ` - Decrement the value at the top of the stack by 1. Stack content: 3
`2  ` - Put the number 2 on top of the stack. Stack content: 3 2
`+  ` - Add the two numbers on top of the stack. Stack content: 5
`2  ` - Put the number 2 on top of the stack. Stack content: 5 2
`)  ` - Increment the value at the top of the stack by 1. Stack content: 5 3
`;  ` - Remove the top element from the stack. Stack content: 5

GolfScript will by default print anything left on the stack after execution has finished.

Can you explain that for people who don't speak GolfScript please?

Thanks. (I'll upvote later because I reached my daily limit, here's a beer.)

Simple and cheaty, I love it. +1

i like it becaus it doesn't seem like it's tricking you with math or semantics, it seems so straightforward and yet 5 ^^

Maybe using `print` will catch more programmers. Then again, most programmers know `echo`!

• ## Java

Always have to round your doubles, folks

``````public class TwoPlusTwo {
public static void main(String... args) {
double two = two();
System.out.format("Variable two = %.15f%n", two);
double four = Math.ceil(two + two); // round just in case
System.out.format("two + two = %.15f%n", four);
}

// 20 * .1 = 2
private static double two() {
double two = 0;
for(int i = 0; i < 20; i++) {
two += .1;
}
return two;
}
}
``````

Output:

``````Variable two = 2.000000000000000
two + two = 5.000000000000000
``````

Explanation:

No, seriously, you always have to round your doubles. 15 isn't enough digits to show that the `two()` method actually produces `2.0000000000000004` (16 is enough, though).

In the raw Hex representations of the numbers, it's only a 1 bit difference (between `4000000000000001` and `4000000000000000`)... which is enough to make the `Math.ceil` method return 5, not 4.

`Math.ceil(two + two); // round just in case` I see what you did there

Making both a function and a variable with the same name... Wow.

If you chose a small enough increment, could you get your `two()` up to `2.5`?

@BenJackson if I did, the function `two()` wouldn't return `2` anymore.

@configurator that's nothing, there isn't even a class named `two`. Production grade java is `Two two = Two.two.two();` with Two.two being of type TwoFactory.

Two.Infinity.And.Beyond()

Ugh, too many twos to count!

@Caleb oh please all languages have issues with `double` rounding

@durron597: Not "all". Perl 6 for example doesn't have problems with this example.

Why is ```two = 2.0000000000000004```? As far as I see it, ```two = .1 * 20```, so where does the 0.0000000000000004 come from?

@ACarter Thats because 0.1 can't be represented exactly in the double datatype.

@RalZarek you mean 1/10 can't be represented exactly? o_O

@nyuszika7h doubles are stored in base 2 internally. This means that only fractions where the denominator is a power of 2 have a finite number of "decimals". 1/10 for example is .001100110011... in base 2.

@RalZarek that's interesting, I didn't know.

@TimS I ceil what you did there

@JannisFroese this is now my favourite comment on this SE

• # BBC BASIC

EDIT: For Andrea Faulds and Squeamish Ossifrage, a more convincing version using a different interpreter: http://sourceforge.net/projects/napoleonbrandy/

``````  MODE 6
VDU 23,52,254,192,252,6,6,198,124,0
PRINT
PRINT "2+2=";2+2
PRINT "2+3=";2+3
``````

This actually prints the number 4, but the `VDU 23` redefines the font for ASCII 52 so that it looks like a 5 instead of a 4. Screen mode 6 was selected for aesthetic reasons (characters of a reasonable size.)

The original image using the emulator at http://bbcbasic.co.uk/bbcwin/bbcwin.html. (with slightly different code) can be seen in the edit history.

Those fonts look different though. Do you think you could make it use the correct font?

@AndreaFaulds I'm using the emulator from http://www.bbcbasic.co.uk/bbcwin/bbcwin.html. It supports the font redefinition of original BBC Basic on an 8x8 grid. But the default font of the emulator is clearly higher res than 8x8. So I could probably do a better job, but it wouldn't be perfect. I suppose I could redefine the font for all 5 as well as 4, then they would look the same.

@AndreaFaulds The question didn't say that the result should be indistinguishable from other 5s. I think this is actually a feature. `2+3=5` and `2+2=5'`

This matches the original font in the BBC Micro: `VDU 23,52,126,96,124,6,6,102,60,0`

@squeamishossifrage thanks for the info. It won't match the font in the emulator though. Your example is 7 pixels high, just like mine. Also it has a zero at the bottom, just like mine, whereas it looks like I need to move it down a bit (i.e, have the zero at the top instead of the bottom.) A key difference is that I have 126,64 whereas you have 126,96, and you have some 6's instead of my 2's. That's because the original BBC font had thick vertical lines, so it could be read easily in 80 column format on a standard TV screen.

@squeamishossifrage I tried another interpreter, which uses a similar (but not identical) 8x8 font and got much more convincing results. Your original font does look 100% authentic though.

@BenJackson and I didn't think it did, but it would be so much nicer if it looked the same :(

@AndreaFaulds Take a look at the answer now. I fixed this a couple of days ago by using Brandybasic instead of BBCwin. The one I used before is a much better emulator in general, but in this case the fact that Brandybasic uses an 8x8 font made it possible to copy the font exactly.

@steveverrill Aha, awesome :)

This trick would also work on the Amstrad CPC (464, 6128, etc.), however, if you try to copy the character back into memory (e.g. with the copy cursor) it will read both `4` (which now looks like `5`) & `5` as `4`, because it tries to match the pattern of pixels to a character and `4` comes before `5`!

• ## Brainfuck

``````+++++           +++++
+               +
+     +         +     +++++
+++++    +++    +++++
+         +     +         +++++
+               +
+++++           +++++.
``````

Output:

``````5
``````

Try it here.

I know this might sound a little to simple, but I tried to be creative, as suggested in original post.

I don't know brainfuck, it took me a couple of minutes to figure this out. ASCII 53, right?

As long you have the `+++++.` you can paint anything.

@steveverrill : yes you are right. (and this is the only way to output ascii characters in BF).

• # Bash

Since this is a , I guess I should use a long-winded method...

For people who don't know Bash: `\$((...expr...))` is a syntax to evaluate arithmetic expressions. `\$(bc<<<...expr...)` does the same using the `bc` command-line calculator.

``````v=2                     #v is 2
v+=2                    #v is 4
v=\$((\$v*5))             #v is 20
v=\$((\$v-16))            #v is 4
v=\$(bc<<<"sqrt(\$v)+2")  #v is 4 (sqrt(4) is 2)
v=\$(bc<<<"\$v/4+3")      #v is 4 (4/4 = 1)
echo '2+2=' \$v          #So v is 4...?
``````

## Output

``````2+2= 5
``````

## Explanation

The second line concatenates v and 2 instead of adding them, to make 22.
Actual explanation:
` v=2 #v is 2 v+=2 #v is 22 v=\$((\$v*5)) #v is 110 v=\$((\$v-16)) #v is 94 v=\$(bc<<<"sqrt(\$v)+2") #v is 11 (by default, bc rounds to integers) v=\$(bc<<<"\$v/4+3") #v is 5 (11/4 is 2 with rounding) echo '2+2=' \$v #TADAAAM`

Nice maths trick going on there!

@tomsmeding It was quite fun, although about halfway through I realised that I had put `15` instead of `16` in line 4. Luckily, it still worked because of `bc`'s rounding

Oh this is just fabulous. lmao

See if you like the look of this style which is also valid Bash (eliminates the dollar signs, allows spaces around the equal sign and allows combined assignment operators): `((v = v * 5))` or `((v *= 5))`

Nice one, but I spotted the `+=` thing immediately.

@nyuszika7h It's probably easy to spot if you're very familiar with Bash. But users of other languages will expect Bash to handle `2` as an integer.

i don't understand how this meets the requirements. there isn't a single addition expression of the form "2+2" anywhere in the code. the only underhanded aspect of this code is the misleading comments. you could have read the value "A=2.5" from a file, added a false comment that says it has the value "A=2", and then printed the result of "A+A"

@ardnew yes there is. the first two lines (`v=2` and `v+=2`): to someone unfamiliar with Bash variable handling, that would be equivalent to `2+2`, but it is in fact `"2"+"2"`, i.e. `"22"`. the other comments in the code are only wrong because of this. I know, not everyone finds this funny

• # Python

``````>>> patch = '\x312\x2D7'
>>> 2 + 2
5
``````

Like Java, CPython uses the same memory location for any copy of the first few small integers (0-255 if memory serves). This goes in and directly edits that memory location via `ctypes`. `patch` is just an obfuscated `"12-7"`, a string with `len` 4, which `eval`'s to 5.

### A more obfuscated version

``````exec("\x66\x72\x6f\x6d\x20c\x74\x79\x70e\x73\x20\x69\x6d\x70\
\x6f\x72\x74\x20c\x5f\x69\x6e\x748\x20a\x73\x20x\x3bf\x72\x6f\
\x6d\x20\x73\x74\x72\x75c\x74\x20\x69\x6d\x70\x6f\x72\x74\x20\
ca\x6cc\x73\x69\x7ae\x20a\x73\x20x0\x3bx\x2ef\x72\x6f\x6d\x5f\
a\x64\x64\x72e\x73\x73\x28\x69\x64\x284\x29\x2bx0\x28\x27\x50\
\x50\x27\x29\x29\x2e\x76a\x6c\x75e\x3d5")
``````

## Beyond 2+2

As OP mentioned, 2+2 can be kinda boring; so here's some cleaner, multiplatform, multi-width code for wanton abuse.

``````from __future__ import division, print_function
import struct
import ctypes
import random

# Py 2.7 PyIntObject:
#     - PyObject_HEAD_EXTRA [usually nothing unless compiled with DEBUG]
#     - (Py_ssize_t) ob_refcnt
#     - (_typeobject) *ob_type
# - (long) ob_ival

# two platform-sized (32/64-bit) ints (ob_refcnt and *ob_type from above)
offset = struct.calcsize('PP')

num = 60
nums = list(range(num))
addresses = [id(x) + offset for x in nums]
random.shuffle(nums)

for a, n in zip(addresses, nums):

print('2 + 2 =', 2+2)
print('9 - 4 =', 9-4)
print('5 * 6 =', 5*6)
print('1 / 0 =\n', 1/0)
print('(1 + 2) + 3 = ', (1+2)+3)
print('1 + (2 + 3) = ', 1+(2+3))
print('(2 + 3) + 1 = ', (2+3)+1)
print('2 + (3 + 1) = ', 2+(3+1))
``````

Running with Python 2.7...ignore that line at the end. Works in Windows 64-bit and Ubuntu 32-bit, the two systems I have easy access to.

``````\$ python awful.py
2 + 2 = 24
9 - 4 = 49
5 * 6 = 55
1 / 0 = 0.76

(1 + 2) + 3 =  50
1 + (2 + 3) =  68
(2 + 3) + 1 =  50
2 + (3 + 1) =  61
Segmentation fault (core dumped)
``````

Unsurprisingly, we can break the associative property of addition, where (a + b) + c = a + (b + c), as seen in the 1st and 2nd `1+2+3` lines, but inexplicably we also break the commutative property (where a + b = b + a; 2nd and 3rd lines). I wonder if the Python interpreter just ignores superfluous parentheses around addition expressions.

Yes, we definitely all just casually ignore segfaults...

It's worth mentioning that this isn't really a Python trick and is only specific to the C implementation of Python.

Python 2.7.6, windows, 64-bit did not work with `from_address(id(4)+8))`. I changed this to `from_address(id(4)+16))` and it worked fine. Are you sure your windows 64-bit installation is 64-bit python, or is it 32-bit python running in 64-bit windows?

@DavidJFelix I fully know that the short example at the top doesn't work in x64 without a correction like you make. That's why I mention my subsequent code being "multi-width", wherein it uses `struct.calcsize('PP')` to come up with the offset

@NickT Ah! okay. I was under the impression that you had tried the original under the same 64-bit windows, 32-bit ubuntu setup

`exec('\x66\x72\x6f\x6d\x20\x63\x74\x79\ \x70\x65\x73\x20\x69\x6d\x70\x6f\ \x72\x74\x20\x63\x5f\x69\x6e\x74\ \x38\x3b\x20\x69\x6d\x70\x6f\x72\ \x74\x20\x73\x74\x72\x75\x63\x74\ \x3b\x20\x63\x5f\x69\x6e\x74\x38\ \x2e\x66\x72\x6f\x6d\x5f\x61\x64\ \x64\x72\x65\x73\x73\x28\x69\x64\ \x28\x34\x29\x20\x2b\x20\x73\x74\ \x72\x75\x63\x74\x2e\x63\x61\x6c\ \x63\x73\x69\x7a\x65\x28\x27\x50\ \x50\x27\x29\x29\x2e\x76\x61\x6c\ \x75\x65\x3d\x35')` Is a modified first version. I made this so I could drop it into \$PYTHONSTARTUP in /etc/profile as red team in hacking competitions.

@DavidJFelix that's awful :P

@NickT It's not the most underhanded thing I've done for red team tactics. I actually think you could probably break 3/5 python scripts if you changed the value of 1 to 0.

Something is messed up with my paste... I don't think it handled my code correctly above.

@DavidJFelix it probably converted newlines into spaces, so then your backslashes don't mean anything

Yeah. Sidenote, it seems that 1, 0 and -1 are some of the numbers that python immediately segfaults with. I was thinking those would be the worst for screwing up python programs behavior. It may be possible to utilize fuckitpy to contain these errors.

@professorfish I wanted to upvote your comment, but I don't want to change the number of 42 votes :P

@DavidJFelix: I don't think fuckitpy contains segfaults. It would be rather impressive if it did. (I can think of one way: trap the segfault, longjmp out of the broken stack frame, and resume execution at the next bytecode...but this will probably cause a ridiculous amount of breakage)

FYI, for anyone looking to continue being a jerk in python3, Python 3 uses longs now. In python3 64 bit, the byte offset seems to be "24" or `calcsize('PPP')`. I haven't tested this in 32bit yet.

eek... don't try the 1/0 one

• # JavaScript:

``````g = function () {
H = 3
return H + H
}

f = function () {
Η = 2
return Η + H
}

// 3 + 3 = 6
// 2 + 2 = 5
``````

Check it at http://jsfiddle.net/qhRJY/

Both H (Latin letter capital h) and Η (Greek letter capital eta) are set to the global scope because they were not defined as local to the functions with the var keyword. While they look similar, they are actually 2 different variables with 2 different values. Using Ctrl+F in your browser you will find that Η (eta) shows up significantly less than H (h) on this page.

@Sam even though the two 'H's look the same, they are in fact 2 entirely different characters. In Unicode there can be different characters that look the same but have different code-points. In this specific case; the other "H" is actually the greek letter Eta.

Using homoglyphs to "confuse" readers is now officially not funny.

The homoglyphs become funny in combination with javascript's ridiculous global variables.

This is not `2+2=5`, it is `2+2'=5` note the ref on the 2nd 2. not the same

smart! I liked it.

@Funkodebat what do you mean by that?

It's not the "Unicode Η character", it's Latin H and Greek Eta (Η).

On my screen it might as well be saying `2+3=5`, which doesn't seem underhanded at all. That's exactly what I would expect.

I didn't realize that if you don't use the var keyword, the variable is global. interesting

@KonstantinWeitz he's not doing h + h, because in the example, one of the h's is not h, its like doing a + b. one of the h's isn't 2. its like saying `2 + (not really 2) = 5`

@JanDvorak The problem with "officially" is that only 27 people at this time have agreed to make it official. Posting in that thread does not make it authoritatively not funny.

@Vortico hmm... what do you wish when a FAQ question doesn't suffice? A FAQ question linked from the help center? Note that only moderators can apply the [meta-tag:faq] tag. As for the answer - the question states "score +5 or more and at least twice as many upvotes as downvotes". The answer has 27 upvotes and no downvote. That sounds to me like fulfilling the criteria stated in the answer, and the amount of upvotes is pretty impressive for the second oldest answer on a question on the meta site of a site where only 124 people have voted more than 10 times. How many would _you_ like? Everyone?

@JanDvorak If those who agree would downvote this question, there would be no need for a meta question like that. The community will eventually grow sick of this kind of humor and no longer upvote these answers, so there is no need for a remark to remind people that humor is objective.

@Vortico well, I did downvote. I am genuinely surprised by the amount of upvotes this has got. Reddit?

Just not funny as the C(From Michael) example.

@Funkodebat: By that same logic the C example is not doing `2+2=5`, but rather `2+2+1=5` and wouldn't be special either.

Haha, on mobile it's grey and very obvious

You can also mess with the `alert()` and/or `console.log()` functions themselves. For instance: https://jsfiddle.net/uk1v0mv0/2/

Content dated before 6/26/2020 9:53 AM
• {{ error }}