[Question]
  [
I have a problem at work. I need to compare two numbers that come as strings from two different databases. The numbers may come with leading zeroes and/or leading/trailing spaces. So I may have `"0001 "` from one database and `" 1 "` from the other one.
I solved the problem in C# with the following code:
> 
>  `Func<string, string, bool> f = (a,b) => int.Parse(a.Trim()) == int.Parse(b.Trim())`
> 
> 
> 
**The challenge**
This is a really simple challenge, suitable for beginners and any kind of esoteric languages. Given two numbers as strings that may come with leading zeroes and/or leading/trailing spaces, write the shortest code that checks if the two strings represent the same number.
* The inputs need to be two strings or the equivalent in your language (a char array is OK), and they will always represent integer values greater than zero.
* The output must be any two consistent values that represent a truthy value and a falsey value.
**Examples**
```
A          B          Result
----------------------------
"0001"     "1    "    true
"1450"     "1450 "    true
"0010001 " " 10001  " true
"0010000"  "  10  "   false
"101023"   "101024"   false
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so may the shortest code for each language win!
  
[Answer]
# [Javascript](https://www.javascript.com/), 11 bytes
```
a=>b=>+a==b
```
Abusing Javascript's casting rules a bit; `+a` coerces `a` into a numeric type.
*-6 bytes* thanks to [Shaggy](https://codegolf.stackexchange.com/questions/152860/compare-two-numbers-given-as-strings/152873?noredirect=1#comment373423_152873) and [Martin Ender♦](https://codegolf.stackexchange.com/questions/152860/compare-two-numbers-given-as-strings/152873?noredirect=1#comment373424_152873)
Also a cool take by [LiefdeWen](https://codegolf.stackexchange.com/questions/152860/compare-two-numbers-given-as-strings/152873?noredirect=1#comment373425_152873):
```
a=>b=>~~a==~~b
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 1 byte
```
Q
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/8P9/AwNDAyBW4FKA0AoA "05AB1E – Try It Online")
**Explanation**
Comparison for equality `Q` will automatically try to evaluate strings as ints before comparing.
[Answer]
# [Operation Flashpoint](https://en.wikipedia.org/wiki/Operation_Flashpoint:_Cold_War_Crisis) scripting language, 33 bytes
```
f={call format(["%1==%2"]+_this)}
```
**Call with:**
```
hint format["%1\n%2\n%3\n%4\n%5",
    ["0001", "1    "] call f,
    ["1450", "1450 "] call f,
    ["0010001 ", " 10001  "] call f,
    ["0010000", "  10  "] call f,
    ["101023", "101024"] call f]
```
**Output:**
[![](https://i.stack.imgur.com/yx1eJ.jpg)](https://i.stack.imgur.com/yx1eJ.jpg)
## Alternative version (41 bytes):
```
f={{t=call _x;r=t==s;s=t}forEach _this;r}
```
Still 5 bytes shorter than the more straightforward `f={t=_this;call(t select 0)==call(t select 1)}`
**39 bytes:**
```
f={{t=call _x;r=t==s;s=t}count _this;r}
```
`count` (which returns the size of an array) works instead of `forEach`, because you can give it a "lambda" that is used as a condition to count only the array elements that meet that condition. The "condition" used in this case is not a valid condition, but it doesn't matter here because it doesn't cause an error and the return value of the `count` is not needed.
[Answer]
# [Taxi](https://bigzaphod.github.io/Taxi/), 488 bytes
```
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Equal's Corner.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:n 1 l 1 l 1 l.Switch to plan "b" if no one is waiting.'1' is waiting at Writer's Depot.[b]'0' is waiting at Writer's Depot.Go to Writer's Depot:n 1 l 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.
```
[Try it online!](https://tio.run/##lVHLCsIwELz7FYOX3kLrsUcfeFRQ8CAe0rJtF0tSk0j162v6UHyA4sKy7DCZ2TBOXrhplhpOY62twyrLOKW4RoTSt2mnWHN6PFeQqKS1pHIyyDWrvH21LQhTmVCZsS3IXP8j987vcGzv9l/VFqezLAOLmTaK/qL2tq9grAbTrsWmZpcWLa0qpcI4GYMzKA2tCGxRS3ZeXARR8LRCOuwMOzJed06VdmKfHILwB6e/5xV83PP9Z0@pic8cVZfhZMixacIwCn2NgHbC1w0 "Taxi – Try It Online")
Ungolfed:
```
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to The Babelfishery.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: south 1st left 1st right.
Pickup a passenger going to Equal's Corner.
Pickup a passenger going to Equal's Corner.
Go to Equal's Corner: north 1st left 1st left 1st left.
Switch to plan "b" if no one is waiting.
'1' is waiting at Writer's Depot.
[b]
'0' is waiting at Writer's Depot.
Go to Writer's Depot: north 1st left 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st right 2nd right 1st left.
```
Taxi is (relatively) well-suited to this challenge because strings are the only input or output type allowed. `The Babelfishery` is what converts strings to number (and vice versa) and it handles stripping all the spaces and leading zeroes. It will also handle negative numbers if the `-` is immediately before the first digit. After that, `Equal's Corner` checks the two values against each other and `Writer's Depot` provides the output in string format. Output is `1` for truthy and `0` for falsey.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 27 bytes
```
f(s,t){s=atoi(s)==atoi(t);}
```
With `-O0` (which is the default setting).
[Try it online!](https://tio.run/##hY5BCoMwEEX3nmIIFDJgIVG7Em/SjUSULExLk5149vgzbts6m3nMPD7f3Rfncp51rBNvcRjTy@vIwwmJ@z37kGgdfdBcbRVh3h@cZq1u0zOomkDGGAtStrwVc//Ds93DiIf9z0NciaTi0onXuiQT9K8uniQV4DatlCjUibrnAw)
# C, 32 bytes
```
f(s,t){return atoi(s)==atoi(t);}
```
[Try it online!](https://tio.run/##hY67CsMwDEX3fIUwFCxIwW7TKeRPugS3KR7qFkeZQr7dvVbXPrToIB0uN@xvIZQy2bkVXvNVlpxolEe0Mw@DgnC/lZiE7mNMlpu1Icwz4zRZs7uck2kJ5JzzIOPr2zD3XzzfnZx62L88xNVIqi698b@uyQT9o4snaQW4h6OWqNSpupUX)
[Answer]
# [J](http://jsoftware.com/), 4 bytes
```
=&do
```
Compare `=` after `&` evaluating `do`. Can also be `=&".`
[Try it online!](https://tio.run/##y/r/P81WT8FWTUnvf2pyRr6CuoGBgaG6AhikAbG6IYgFFuCCKDA0MTVAUQDkoygAGgAyBCQGVqAA4QIZKArAhkAUAFVA7IBZAVRgZKyOsALENwHx/wMA "J – Try It Online")
[Answer]
## [Retina](https://github.com/m-ender/retina), 11 bytes
```
.+
$*
D`
¶$
```
[Try it online!](https://tio.run/##K0otycxL/K@qEZyg819Pm0tFi8slgevQNpX//w0MDAx1DBWAgMvQxNRAB0QocAEFQRIKOgoQGiZioKMAFAGpBXKNjHXAlAkA "Retina – Try It Online")
Input is linefeed separated, but the test suite uses comma separation for convenience. Prints `1` for equality and `0` for inequality.
### Explanation
```
.+
$*
```
Convert each line to unary. This ignores leading zeros and spaces.
```
D`
```
Deduplicate: clear the second line if both are the same.
```
¶$
```
Check that the string now ends in a linefeed.
[Answer]
# [Python 3](https://docs.python.org/3/), 25 bytes
```
lambda a,b:int(a)==int(b)
```
[Try it online!](https://tio.run/##TY49DsMgDIV3TmF5ChWDadIlEiehDKAWNVJLosCS01NMVKlenvW955/tKK81jTWae337T3h48CrMSyqDl8awBlnLM5cMBqxFItKoADW0Qqcs6ulGqLqcoCU4BRyDs/03qPNm/OYbvY59J3cTOidEXHfgq7CkrnkWsO38ThwuDKSsXw "Python 3 – Try It Online")
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 22 bytes
```
(([{}]{})[{(){}}](){})
```
[Try it online!](https://tio.run/##SypKzMzTTctJzP7/X0Mjuro2trpWM7paQ7O6tjYWRGr@/29gYGgAxFwKYEoBAA "Brain-Flak – Try It Online")
Saved 4 bytes thanks to [Jo King](https://codegolf.stackexchange.com/users/76162/jo-king).
[Answer]
# [Triangularity](https://github.com/Mr-Xcoder/Triangularity), 17 bytes
```
..)..
.Ii).
@Ii=.
```
[Try it online!](https://tio.run/##KynKTMxLL81JLMosqfz/X09PU0@PS88zU1OPy8Ez01bv/38DA0MDIOYCkwA "Triangularity – Try It Online")
Triangularity is, for once, competitive!
### How it works
Triangularity requires the code to have a triangular distribution of the dots. That is, the length of each row must be equal the number of rows multiplied by 2 and decremented, and each row must have (on each side) a number of dots equal to its position in the program (the bottom row is row 0, the one above it is row 1 and so forth). Keeping this in mind, let's analyse how the code works:
```
..).. || Push a 0 onto the stack.
.Ii   || Get the 0th input and cast it to an integer.
   ). || Push another 0 onto the stack.
@I    || Increment the ToS => 1. Get the first input.
  i=. || Then cast it to an integer and compare their equality.
```
[Answer]
## [Alice](https://github.com/m-ender/alice), 7 bytes
```
X/n
o@i
```
[Try it online!](https://tio.run/##S8zJTE79/z9CP48r3yHz/38DAwNDLkMFIAAA "Alice – Try It Online")
Any non-digit separator works. Prints `1` for equality and `0` otherwise.
### Explanation
```
X   XOR, does nothing.
/   Switch to Ordinal mode.
i   Read all input as a string.
/   Switch to Cardinal mode.
X   XOR. Implicitly finds all integers in the string and pushes them separately
    onto the stack. The XOR gives 0 if the values are identical.
n   Logical NOT. Gives 1 for equal inputs and 9 otherwise.
/   Switch to Ordinal.
o   Print the 0 or 1 as a string.
/   Switch to Cardinal.
@   Terminate the program.
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt/), 3 bytes
```
¥Vn
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=pVZu&input=IjA4IiAKIiA4ICI=)
Converts the second input to an integer and compares equality with the first.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 4 bytes
*3 bytes saved thanks to @Adám*
```
=/⍎¨
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R2wRb/Ue9fYdWADkK6gYGBobqCuqGCkCgzgUUMDQxNVCHUArqIFEusCpDkEKggLoChAVkICRAGhSAEgpgHWBTgOJGxupQhglIGAA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# jq, 24 characters
```
map(tonumber)|.[0]==.[1]
```
The 2 strings are passed as items of an array.
Sample run:
```
bash-4.4$ jq 'map(tonumber)|.[0]==.[1]' <<< '["0010001 ", " 10001  "]'
true
bash-4.4$ jq 'map(tonumber)|.[0]==.[1]' <<< '["0010000", "  10  "]'
false
```
[Try it online!](https://tio.run/##yyr8/z83sUCjJD@vNDcptUizRi/aINbWVi/aMPb//2glAwNDAyBWUNJRUFKAMBWUYgE "jq – Try It Online") ([All test cases](https://tio.run/##lY7NCsIwEITP9imWPbVQQ6L1UuiTxByqRlD6Z5qCYH11Y7ZFKUUPzSU7y3w7c705x6SCHtDq1oJ/KexDRiLCGNDotivsZNuXeRPauurKgzZRzyRXWcakUINd3xt9tPo02D8iwpVzMqDjjyEGU5DIORdIO48J@kmoyQ3vsqbT8IznqEh2/Iv6eQHqQykYqCyMI@AS1AcT6tmh8Qw950WrfxT26GaLY2Gak39ooF51Yy911bq1eQM "jq – Try It Online"))
[Answer]
# [Husk](https://github.com/barbuz/Husk), 3 bytes
```
¤=r
```
[Try it online!](https://tio.run/##yygtzv6vcGhbrtujpsb/h5bYFv3//z9aQ8nAwMBQSUfJUAEIlDR1NJQMTUwNQAJACiIAVABSpAAUVICwkMVBahWA4jDdQEEjY5B@EMNESTMWAA "Husk – Try It Online")
### Explanation
```
¤    -- combine both arguments of ..
 =   -- .. equality ..
  r  -- .. with read
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 20 bytes
```
param($a,$b)+$a-eq$b
```
Similar to the JavaScript answer, just longer because PowerShell doesn't have currying. Uses `+` to cast the first string to integer, and then the `-eq`uals automatically casts the second string to integer. Output is True/False.
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/vyCxKDFXQyVRRyVJU1slUTe1UCXp////6gYGBobq/9UVDBUU1AE "PowerShell – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
t€⁶V€€ḌE
```
[Try it online!](https://tio.run/##y0rNyan8/7/kUdOaR43bwkBU05qHO3pc////H61kYGBgqKSjoGSoAARKsQA "Jelly – Try It Online") or see the **[test suite](https://tio.run/##y0rNyan8/7/kUdOaR43bwkBU05qHO3pc/x9uB7Ii//@PVjIwMDBU0lFQMlQAAqVYHYVoJUMTUwOwEJCGCgEVgRQqgIQVIEwUGZB6oAxQCm4IUNzIGGwMiGWiFAsA "Jelly – Try It Online")**
35 answers, and no Jelly submission? Takes the argument as a list (`["0001", "1 "]` for the first example)
## How it works
```
t€⁶V€€ḌE - Main link. Argument: list       e.g.    ["0001", "1    "]
 €       - For €ach element...                     ["0001", "1"]
t        -   trim from both sides...
  ⁶      -   spaces
     €   - For €ach element...
   V€    -   evaluate €ach character               [[0, 0, 0, 1], [1]]
      Ḍ  - Convert from digits                     [1, 1]
       E - Are they equal?                         1
```
[Answer]
# Excel, 8 bytes
```
=A1-B1=0
```
Excel does the string to num conversion for us.
(To input as string, prefix values with `'`.)
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 19 bytes
```
$args-join'-eq'|iex
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/XyWxKL1YNys/M09dN7VQvSYzteL////qCkBgAALmlgrq/9WBpII6AA "PowerShell – Try It Online")
`-join` the argument array (`$args`) with the string representation of the comparison operator (`-eq`) then evaluate the expression with `Invoke-Expression` (`iex`).
[Answer]
# Q (Kdb+), 13 bytes
```
=/["J"$(x;y)]
```
## Explanation
(x;y) : a list of the two inputs. 
"J"$ : casting each input to a long (7j) type from string (10c), which can correctly interpret  
 white space and leading 0s. 
=/ : checks equality over elements in a list (each subsequent pair).  
As there is only one pair, returns single boolian 0b/1b.
[Answer]
# T-SQL, 35 bytes
[Per our standards](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/5341#5341), data is input via pre-existing table `t` with `varchar` fields `a` and `b`.
```
    SELECT IIF(ABS(a)=ABS(b),1,0)FROM t
```
Returns `1` if they match, `0` if they don't.
A few of SQL's mathematical functions (including `ABS`, `FLOOR` and `CEILING`) will do an implicit conversion to numeric if given string parameters, this is shorter than an explicit `CAST(a AS INT)` or `CONVERT(INT,b)`, and works in this case since we know the input values are always positive.
`IIF` is specific to MS SQL 2012 and above, so no guarantee about other implementations.
[Answer]
# Excel VBA, 27 16 Bytes
-9 Thanks to @Nayrb and @TaylorScott
```
[C1]=[A1]-[B1]=0
```
Where you input the values on the Cells with `'string`.
Where `x` and `y` are the input Strings and `z` is a Boolean output.
If CInt(x)=CInt(y) Then z=1
Using [CInt](https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/type-conversion-functions)
[Answer]
# [R](https://www.r-project.org/), ~~28~~ 27 bytes
```
!diff(as.double(scan(,'')))
```
Reads numbers as strings, converts them to doubles and checks if their difference is not zero. 
[Try it online!](https://tio.run/##K/r/XzElMy1NI7FYLyW/NCknVaM4OTFPQ0ddXVNT87@6goIBEBgZKyioK6gbGav/BwA "R – Try It Online")
*−1 byte thanks to [Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe)*
[Answer]
# [Lua](https://www.lua.org), 20 bytes
```
print(...-arg[2]==0)
```
[Try it online!](https://tio.run/##yylN/P@/oCgzr0RDT09PN7EoPdoo1tbWQPP///8KCgYGpqYK/01NAQ "Lua – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 20 bytes
*-11 bytes thanks to Laikoni. -2 bytes thanks to Zgarb.*
```
a#b=0+read a==read b
```
[Try it online!](https://tio.run/##bY07DoBACER7TzFBOxvWT7mHwWii8Rv1/uuimxg/NDDMY2hl65thcE7iynK6NlJDrD175UbpJljUcwRfy9pNOxIQMxvSDWKQAT1dU5R8u168AX@tCSAFEOY/RGMu5PPD@1lO4YeKgtwB "Haskell – Try It Online")
[Answer]
# [Gema](http://gema.sourceforge.net/), 21 characters
```
*\n*=@cmpn{*;*;0;1;0}
```
No boolean in Gema. As the `@get-switch{}`/`@set-switch{}` functions use 0 and 1 to represent switch statuses, also used 0 and 1.
The 2 strings are passed on separate input lines.
Sample run:
```
bash-4.4$ gema '*\n*=@cmpn{*;*;0;1;0}' <<< $'0010001\n10001  '
1
bash-4.4$ gema '*\n*=@cmpn{*;*;0;1;0}' <<< $'0010000\n  10  '
0
```
[Answer]
# Perl 5, 9 + 1 (`-p`) = 10 bytes
```
$_=$_==<>
```
[try it online](https://tio.run/##K0gtyjH9/18l3haIbG3s/v83MDAwVAABLkMIaWJqoIBgcQGlwUq4FCA0TMSASwEoAlIG5BoZQyiTf/kFJZn5ecX/dQtyAA)
[Answer]
# [Stacked](https://github.com/ConorOBrien-Foxx/stacked), 8 bytes
```
[#~\#~=]
```
[Try it online!](https://tio.run/##VYzRCsIwDEXf@xUXKmQDLaluLwPF/5gDh/ZJxDK71/16TSpDbEo4nOTmncbbI9xz7u1ysctxyOcuGFMZoCJm9gR95Euvi/ZNy6sWXLUsawAk9aX/iWbke/4dEr8/UDmk2Iiv0cusw2YKccJzjKCtxOwVcU4Cu5M0ReccAl5zMoOu5Q8 "Stacked – Try It Online")
## Explanation
```
[#~\#~=]   anonymous function
 #~        eval TOS
   \       swap top two
    #~     eval TOS
      =    push equality of top two
```
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/attache), 11 bytes
```
Same@Map&:N
```
[Try it online!](https://tio.run/##SywpSUzOSP3vkpqWmZcarZKm8z84MTfVwTexQM3K738sV0BRZl6JQ5qCrZ1CWDSXApBQMjAwMFTSUVAyVFCK1YEIGZqYGoCFgDRCFKgOpFYBJKMAZaLKGUClkEwCihsZg80CsUyUYrli/wMA "Attache – Try It Online")
This takes an array of strings, such as `V["0001", "1 "]`. Simply stated, `Map&:N` is a function that maps `N` over its argument, and `Same` checks that the array contains only equal members. (Fun fact: this function works for more than 2 string arguments.)
[Answer]
# [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), 42 bytes
```
	OUTPUT =EQ(EVAL(INPUT),EVAL(INPUT)) 1
END
```
[Try it online!](https://tio.run/##K87LT8rPMfn/n9M/NCQgNETB1jVQwzXM0UfD0w/I1dRBYmsqGHK5@rn8/29gYGgABFwKCoYGCgoA "SNOBOL4 (CSNOBOL4) – Try It Online")
Outputs 1 for truthy, nothing for falsey. Since  (space) is the concatenation operator in SNOBOL, `EVAL`ing a number with leading/trailing spaces yields the number itself, and it also neatly takes care of any leading zeroes. `EQ` tests for numerical equality, conditionally setting `OUTPUT` to 1 on `Success`.
]