# Test if two numbers are equal

## Challenge

• Input two integers.
• Integer I/O must be decimal.
• If the integers are equal, output a truthy value.
• Otherwise, output a falsy value.

### Clarifications

• You will never receive non-integer inputs.
• You will never receive an input that is outside the bounds [-2³¹, 2³¹).

## Rules

• Standard loopholes are disallowed.
• This is . Shortest answer wins, but will not be selected.
• I can't tell you the reason for the other downvotes, but mine is because I firmly believe that trivial questions like this are bad for the site. -- Peter Taylor – DJMcMayhem May 31 '17 at 20:29
• A reminder: as this is ridiculously trivial in most languages, please vote according to difficulty. Just because it's a 1 byte builtin in some golfing languages doesn't mean those answers are better than well-golfed longer solutions in, say, Brain-Flak. – Rɪᴋᴇʀ May 31 '17 at 20:33
• @All downvoters: If you're downvoting this then you have to downvote the add two numbers challenge and the multiply two numbers challenge too because they're "too trivial". – CalculatorFeline May 31 '17 at 21:01
• @CalculatorFeline But not all trivial challenges are the same level of trivial. In most languages without built-ins to add two numbers or check for equality (especially those without numerical input), I would expect the equality check to be easier to implement. Example: my BF equality check is 45 bytes, while the shortest BF addition program is 224 bytes. – ETHproductions May 31 '17 at 21:10
• So are you trying to rule out a C function like int f(int a, int b){ return a==b;}? Because int in C represents numbers with base-2 bit-patterns, not decimal. (The details are implementation-defined, but there are enough requirements in the C standard that I don't think an implementation could legally choose a BCD (binary-coded-decimal) representation. At least not for unsigned char.) I think you're getting mixed up by source code that looks like int a = 1234;. That uses a decimal representation in the source, but not in the program. int a=0x4d2; is identical to 1234. – Peter Cordes Jan 10 '18 at 4:20

# Braingolf, 4 bytes

e1:0


Outputs 1 if inputs are equal, otherwise 0

### Explanation:

e1:0  Implicit input to stack
e     If last 2 items are equal..
1    ..push 1 to stack
:   else
0  ..push 0 to stack
Implicit endif
Implicit output of last item on stack


# C, 20 bytes

f(a,b){return a==b;}


# Lua, 18 bytes

a,b=...print(a==b)


Try it online!

# 09D, 13 bytes

310310412D301


Outputs 1 if the values are equal, otherwise 0

### Explanation:

310310412D301
3                 Read..
1                ..from I/O (STDIN)
0               ..to stack
310            Read 2nd input as above
4           Apply math function...
12D        ..isEqual, pop both items and push a 1
if they are equal, otherwise push a 0
3       Read..
0      ..from stack
1     ..to I/O (STDOUT)


## Java, 4136 12 bytes

-4 bytes thanks to @totallyhuman - Changed floats to ints

-1 byte by removing space between second method argument and comma.

-24 by converting the whole program to a lambda (woo).

(i,j)->i==j;


Takes the form of a java.util.function.BiFunction< Boolean, Integer, Integer > using an expression lambda.

• @totallyhuman Thanks! Got a bit confused since the description said "2 decimal integers" – Mas May 31 '17 at 22:34
• float isn't decimal either; it's IEEE binary32. "decimal" is a stupid way of describing binary integers. It only makes sense when talking about their string representation, or with decimal floating point (en.wikipedia.org/wiki/Decimal_floating_point), which isn't provided in hardware by most FPUs. IIRC, IBM's POWER architecture has decimal float support, which is useful for some financial stuff. – Peter Cordes Jan 10 '18 at 2:06

# Triangular, 6 bytes

$.$%=<


Try it online!

Formats into this triangle:

  $.$
% = <


Commands executed (without no-ops or directionals): =%

Pretty simple.

• $ - read input as integer • = - compare top two stack values for equality • % - print result # Decimal, 13 bytes 81D81D412D301  Pretty simple. Ungolfed: 81D ; builtin - read INT to stack 81D ; builtin - read INT to stack 412D ; compare for equality 301 ; print to STDOUT  Try it online! # dc, 12 9 bytes [1]sF=F0+  Try it online! # Add++, 3 bytes L,=  Try it online! Yay for lambda functions! # Triangularity, 17 bytes ..).. .I)1. I=...  Try it online! # Triangularity, 17 bytes ..).. .D@I. sI=..  Try it online! # Noether, 4 bytes II=P  Try it online! # Cubically, 8 5 bytes $:$=%  Explanation: $      read integer input
:     set notepad to input
$read integer input = compare notepad to input % print notepad  Try it online! # Whitespace, 60 bytes [S S S N _Push_0][S N S _Duplicate_0][S N S _Duplicate_0][T N T T _Read_STDIN_as_integer][T T T _Retrieve][S S S T N _Push_1][S N S _Duplicate_1][T N T T _Read_STDIN_as_integer][T T T _Retrieve][T S S T _Subtract][N T S N _If_0_Jump_to_Label_EQUAL][T N S T _Print_as_integer][N N N _Exit_program][N S S N _Create_Label_EQUAL][S S S T N _Push_1][T N S T _Print_as_integer]  Letters S (space), T (tab), and N (new-line) added as highlighting only. [..._some_action] added as explanation only. Try it online (with raw spaces, tabs and new-lines only). Outputs 1/0 as truthy/falsey values. 3 bytes could be saved by removing NNN if 1/01 as truthy/falsey values are allowed. Pseudo-code: Integer i = STDIN as number Integer j = STDIN as number If(i == j): Call function EQUAL() Print 0 to STDOUT Exit program function EQUAL: Print 1 to STDOUT Exit automatically with error  # Python 2 - 15 bytes lambda a,b:a==b Like this: def equality(a, b): Declare a function return a == b Return True if equal, False if not  # TI-Basic, 3 bytes not(variance(Ans  Gives {1} as truthy value or {0} for falsy. -1 bytes thanks to lirtosiast! • not(variance(Ans – lirtosiast Nov 24 '18 at 4:09 • @lirtosiast Good tip, thanks! – Timtech Dec 5 '18 at 16:19 # PowerShell, 36 20 bytes -16 bytes thanks to @mazzy (Basically their answer!) !($args[0]-$args[1])  Try it online! Simple. Takes arguments from commandline arguments. • I don't know much about powershell, but aren't you using more bytes to shorten$args to $a than you would be if you just wrote$args twice? – dkudriavtsev Dec 3 '18 at 4:43
• Great! Gabriel Mills, try this !($args[0]-$args[1]) or $a,$b=$args;!($a-$b) or param($a,$b)!($a-\$b) – mazzy Dec 3 '18 at 5:40

# x86_64 machine language on Linux, 8 bytes

0:   31 c0                   xor    %eax,%eax
2:   39 f7                   cmp    %esi,%edi
4:   0f 94 c0                sete   %al
7:   c3                      retq


Try it online!

• Why are you bothering to return a 64 or 32-bit integer truth value? The x86-64 SysV calling convention (used on Linux) only requires bool return values to be in the low 8 bits; the remaining bits of rax are allowed to hold garbage. The only reason you (or gcc) would xor-zero eax would be for performance reasons to avoid a potential false dependency. – Peter Cordes Jan 9 '18 at 13:24
• In assembly language, you should choose your calling convention to optimize for the problem. For example, you should return the compare result in ZF (so ZF=1 means equal). Then the whole function is only 4 bytes. – Peter Cordes Jan 9 '18 at 13:26

# ><>, 3 bytes

=n;


Try it online!

Takes command line arguments.
I feel unclean posting an answer to this one..

# Clam, 5 4 bytes

p:rr


## Explanation

p    - Print...
r  - Next input
:   - Equal to
r - Next input