# 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

# Perl 6, 4 bytes

*==*


Try it

This creates a WhateverCode lambda, Each * represents a parameter

# 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
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
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 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-$args)  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-$args) or $a,$b=$args;!($a-$b) or param($a,$b)!($a-\$b) – mazzy Dec 3 '18 at 5:40

## Keg, 1 byte(SBCS on Keg wiki)

=


## Explanation:

=# Test whether they are equal

• 1 byte – Lyxal Nov 16 '19 at 8:07

# 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..

• Random post: You have 1111 reps now! – HighlyRadioactive Sep 27 '19 at 4:50
• And 1 silver badge, and 11 bronze badges! Gotta say, it really disincentivizes further activity. xD – Reinstate Monica Sep 27 '19 at 11:15
• If only you program with 1+... (Sorry for 1+-promoting) – HighlyRadioactive Sep 27 '19 at 11:20
• Also, you can't stop people from upvoting your awesome answers! (I won't upvote this answer despite it being awesome and written in one of my favorite answer, though, to preserve 1,111) – HighlyRadioactive Sep 27 '19 at 13:21
• I now have 666 reps... – HighlyRadioactive Sep 27 '19 at 13:21

# Clam, 5 4 bytes

p:rr


## Explanation

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


# C, 19 bytes

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


Try it online!

# C, 18 bytes

#define f(a,b) a-b


Try it online!

"Truthy" value is 0 and "Falsy" value is anything but.

## Caboose, 24 bytes

print(input()==input());


TIO

# 1+, 10 bytes

."."\</<*:


This is likely to be ungolfed: tell me if there's a better approach.

Explanation:

First, I'll name the two input A and B.

."." pushes A, duplicate it, pushes B, duplicate it. So now the stack is: A A B B.

\ rotates the stack, so the stack is now B A A B.

</<* Pushes A <= B, move it to the bottom of the stack, and pushes B <= A, then multiply them, as they are both boolean, this is equivalent to the and operation.

: Outputs the result.