[Question]
  [
### Input
The input is a single positive integer `n`
### Output
The output is`n` with its most significant bit set to `0`.
### Test Cases
```
1 -> 0
2 -> 0
10 -> 2
16 -> 0
100 -> 36
267 -> 11
350 -> 94
500 -> 244
```
For example: `350` in binary is `101011110`. Setting its most significant bit (i.e. the leftmost `1` bit) to `0` turns it into `001011110` which is equivalent to the decimal integer `94`, the output. This is [OEIS A053645](https://oeis.org/A053645).
  
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~49~~ ~~44~~ ~~40~~ 39 bytes
```
i;f(n){for(i=1;n/i;i*=2);return n^i/2;}
```
[Try it online!](https://tio.run/##ZY7LCsIwEEX3/YpQEBKxNJm2KRLql4gg1cgsHCXUVem3xz7A2mSW9x7OnTZ7tK33aCwn0duX49goQzka3DcgjLt3H0eMLpiDGfzzisRF0idsvLdD6ixPFctOTLLd7UzpwXIlhNn0sO0h7JWcAFgFMiJ0MKFjxywp9J8l0oCuJ0ip9Rddh1BRzaZj@YPGJISqZQ7KlaqWvcF/AQ "C (gcc) – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 27 bytes
```
lambda n:n^2**len(bin(n))/8
```
[Try it online!](https://tio.run/##K6gsycjPM/qfpmCrEPM/JzE3KSVRIc8qL85ISysnNU8jKTNPI09TU9/if0FRZl6JQpqGoYGB5n8A "Python 2 – Try It Online")
# 26 bytes
Unfortunately, this does not work for `1`:
```
lambda n:int(bin(n)[3:],2)
```
[Try it online!](https://tio.run/##K6gsycjPM/qfpmCrEPM/JzE3KSVRIc8qM69EIykzTyNPM9rYKlbHSPN/QRFQTCFNw9DAQPM/AA "Python 2 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes
```
.²óo-
```
[Try it online!](https://tio.run/##MzBNTDJM/f9f79Cmw5vzdf//NzUwAAA "05AB1E – Try It Online")
Removing the most significant bit from an integer **N** is equivalent to finding the distance from **N** to the highest integer power of **2** lower than **N**.
Thus, I used the formula **N - 2floor(log2N)**:
* `.²` - Logarithm with base **2**.
* `ó` - Floor to an integer.
* `o` - **2** raised to the power of the result above.
* `-` - Difference.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes
```
BḊḄ
```
[Try it online!](https://tio.run/##y0rNyan8/9/p4Y6uhzta/v//b2xqAAA "Jelly – Try It Online")
# Explanation
```
BḊḄ  Main Link
B    Convert to binary
 Ḋ   Dequeue; remove the first element
  Ḅ  Convert from binary
```
[Answer]
# C (gcc) -- 59 bytes
```
main(i){scanf("%d",&i);return i&~(1<<31-__builtin_clz(i));}
```
This gcc answer uses only integer bitwise and arithmetic operations.
No logarithms here! It may have issues with an input of 0, and is totally non-portable.
It's my first answer on this site, so I'd love feedback and improvements. I sure had fun with learning bitwise expressions.
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), 23 bytes
```
n->n^n.highestOneBit(n)
```
[Try it online!](https://tio.run/##NU7BSsNQELznK4ZCIJHk0VZawWpAD4IH8VBvovBMXtKNyb6Qt6mUkm@Pr7Uehhlmd2en1nud2s5wXXxP1Ha2F9TeU4NQo8qBcyHL6moTdMNXQznyRjuHF02MYwBcXCdaPO0tFWj9LNpKT1y9f0D3lYvPq8CbfWZ5umTeeW0q02co7ydOM/5ktaNqZ5y8snkkiTieNue70vYRsYBuweYHXvrgIxYJlgkWc4/1ib1Yrm8SXK@8Ws3nGP8fA9uDE9MqO4jqfDMpo1lYIM0QFiHPElCCUumuaw4PzheLKI7/fo/BCeP0Cw "Java (OpenJDK 8) – Try It Online")
Sorry, built-in :-/
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~8~~ 6 bytes
```
B0T(XB
```
[Try it online!](https://tio.run/##y00syfn/38kgRCPC6f9/QwA "MATL – Try It Online")
Saved two bytes thanks to Cinaski. Switching to assignment indexing instead of reference indexing was 2 bytes shorter :)
### Explanation:
```
          % Grab input implicitly: 267
B         % Convert to binary: [1 0 0 0 0 1 0 1 1]
 0T(      % Set the first value to 0: [0 0 0 0 0 1 0 1 1]
    XB    % Convert to decimal: 11
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 3 [bytes](https://github.com/barbuz/Husk/wiki/Codepage)
```
ḋtḋ
```
[Try it online!](https://tio.run/##yygtzv7//@GO7hIg/v//v7GpAQA "Husk – Try It Online")
**Explanation:**
```
    -- implicit input, e.g. 350
  ḋ -- convert number to list of binary digits (TNum -> [TNum]): [1,0,1,0,1,1,1,1,0]
 t  -- remove first element: [0,1,0,1,1,1,1,0]
ḋ   -- convert list of binary digits to number ([TNum] -> TNum): 94
```
[Answer]
# [Ohm v2](https://github.com/MiningPotatoes/Ohm), 3 bytes
```
b(ó
```
[Try it online!](https://tio.run/##y8/INfr/P0nj8Ob//w0NDAA "Ohm v2 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 27 bytes
```
lambda n:n-2**len(bin(n))/8
```
[Try it online!](https://tio.run/##K6gsycjPM/qfpmCrEPM/JzE3KSVRIc8qT9dISysnNU8jKTNPI09TU9/if0FRZl6JQpqGoYGB5n8A "Python 2 – Try It Online")
# Explanation
```
lambda n:n-2**len(bin(n))/8  # Lambda Function: takes `n` as an argument
lambda n:                    # Declaration of Lambda Function
              len(bin(n))    # Number of bits + 2
           2**               # 2 ** this ^
                         /8  # Divide by 8 because of the extra characters in the binary representation
         n-                  # Subtract this from the original
```
[Answer]
# [Python 3](https://docs.python.org/3/), 30 bytes
*-8 bytes thanks to caird coinheringaahing. I typed that from memory. :o*
```
lambda n:int('0'+bin(n)[3:],2)
```
[Try it online!](https://tio.run/##K6gsycjPM/6fpmCrEPM/JzE3KSVRIc8qM69EQ91AXTspM08jTzPa2CpWx0jzf0ERSDxNw9DAQFPzPwA "Python 3 – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 28 bytes
```
function(x)x-2^(log2(x)%/%1)
```
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP0@jQrNC1yhOIyc/3QjIVtVXNdT8n6ZhqMkFJAwgJJgyMjPX/A8A "R – Try It Online")
Easiest to calculate the most significant bit via `2 ^ floor(log2(x))` rather than carry out base conversions, which are quite verbose in R
[Answer]
## 32-bit x86 assembler, ~~10~~ ~~9~~ 7 bytes
Byte code:
```
0F BD C8 0F B3 C8 C3
```
Disassembly:
```
bsr ecx, eax
btr eax, ecx
ret
```
accepts and returns the value in the eax register.
Perform a reverse scan for the first set bit, and then reset that bit.
[Answer]
# Mathematica, 37 bytes
```
Rest[#~IntegerDigits~2]~FromDigits~2&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@z8otbgkWrnOM68kNT21yCUzPbOkuM4ots6tKD8XxlP7H1CUmVei75Cm71BtqGOkY2igY2gGJA10jMzMdYxNDXRMDQxq/wMA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# JavaScript, ~~22~~ 20 bytes
*Saved 2 bytes thanks to [ovs](https://codegolf.stackexchange.com/users/64121/ovs)*
```
a=>a^1<<Math.log2(a)
```
[Try it online!](https://tio.run/##DcxBDoIwEEDRq7hsk7GZ1oAb8AaewGCYQNESYZp2xOPXbv7u/ZUOylMKUc47z74sfaH@Rk/bdXeSt/nwyynSJSaefM4my8xfMb8UxKuHBQcWwba1CK69wqVBaBAHs1FU9bRUrM3KYR9Poy5/)
### Another approach, 32 bytes
```
a=>'0b'+a.toString`2`.slice`1`^0
```
[Try it online!](https://tio.run/##DcxBDsIgEADAr3grxHWzYFpP9RMejWaRUkOj0MCqz8de5jiL@7rqS1zlkPIU2jw2N547enR7h5IvUmJ6smWsr@gDG75TW0v2oVasMuWP4K9ECepqwIIhMMMmgR1OcOwJeqIbvt2qtnVWTmtccky8Y93@ "JavaScript (Node.js) – Try It Online")
[Answer]
# J, 6 bytes
```
}.&.#:
```
Pretty simple.
### Explanation
```
}.&.#:
    #:  convert to list of binary digits
  &.    apply right function, then left, then the inverse of right
}.      behead
```
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 10 bytes
Tacit prefix function.
```
2⊥1↓2∘⊥⍣¯1
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R2wSjR11LDR@1TTZ61DEDyHzUu/jQekOg1KEVCoYKRgqGBgqGZkDSQMHIzFzB2NRAwdTAAAA "APL (Dyalog Unicode) – Try It Online")
`2∘⊥`… decode from base-2…  
 …`⍣¯1` negative one time (i.e. encode in base-2)
`1↓` drop the first bit
`2⊥` decode from base-2
[Answer]
# Ruby, 26 bytes
-7 Bytes thanks to Ventero.
-2 Bytes thanks to historicrat. 
```
->n{/./=~'%b'%n;$'.to_i 2}
```
[Answer]
# C (gcc), 38 bytes
Built-in in gcc used.
```
f(c){return c^1<<31-__builtin_clz(c);}
```
[Answer]
**Excel, 20 bytes**
```
=A1-2^INT(LOG(A1,2))
```
[Answer]
# Excel, ~~36~~ 31 bytes
`-5` bytes thanks to @IanM\_Matrix1
```
=BIN2DEC(MID(DEC2BIN(A1),2,99))
```
Nothing interesting.
[Answer]
# ARM Assembly, ~~46~~ 43 bytes
(You can omit destination register on add when same as source)
```
clz x1,x0
add x1,1
lsl x0,x1
lsr x0,x1
ret
```
[Answer]
# Pyth, 5 bytes
```
a^2sl
```
[Test suite.](http://pyth.herokuapp.com/?code=a%5E2sl&input=1+%0A2+%0A10%0A16+%0A100%0A267%0A350+%0A500&test_suite=1&test_suite_input=1+%0A2+%0A10%0A16+%0A100%0A267%0A350+%0A500&debug=0)
Explanation:
```
    l   Log base 2 of input.
   s    Cast ^ to integer (this is the position of the most significant bit.)
 ^2     Raise 2 to ^ (get the value of said bit)
a       Subtract ^ from input
```
[Answer]
## [Alice](https://github.com/m-ender/alice), 8 bytes
```
./-l
o@i
```
[Try it online!](https://tio.run/##S8zJTE79/19PXzeHK98h8/9/UwMDAA "Alice – Try It Online")
### Explanation
```
.   Duplicate an implicit zero at the bottom of the stack. Does nothing.
/   Switch to Ordinal mode, move SE.
i   Read all input as a string.
l   Convert to lower case (does nothing, because the input doesn't contain letters).
i   Try reading all input again, pushes an empty string.
/   Switch to Cardinal mode, move W.
.   Duplicate. Since we're in Cardinal mode, this tries to duplicate an integer.
    To get an integer, the empty string is discarded implicitly and the input is 
    converted to the integer value it represents. Therefore, at the end of this,
    we get two copies of the integer value that was input.
l   Clear lower bits. This sets all bits except the MSB to zero.
-   Subtract. By subtracting the MSB from the input, we set it to zero. We could
    also use XOR here.
/   Switch to Ordinal, move NW (and immediately reflect to SW).
o   Implicitly convert the result to a string and print it.
/   Switch to Ordinal, move S.
@   Terminate the program.
```
[Answer]
# [Mathematica](https://www.wolfram.com/wolframscript/), ~~21~~ 17 bytes
```
#-2^Floor@Log2@#&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@19Z1yjOLSc/v8jBJz/dyEFZ7X9AUWZeiUNatKmBQex/AA)
This is my first Mathematica answer, feel free to tell me what have I screwed up.
**-4 bytes** thanks to @HyperNeutrino!
So as it turns out, someone made a similar program before, and sent it to the OEIS. However, keep in mind that the floor of a logarithm is basically defined as the number of digits of a number. This is just a coincidence, or rather a task simple enough that many people will get the same answer.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 bytes
```
^2p¢ÊÉ
```
[Try it online!](https://ethproductions.github.io/japt/?v=1.4.5&code=XjJwosrJ&input=MzUw)
### Explanation
```
^2p¢ÊÉ
   ¢     Get binary form of input
    Ê    Get length of that
     É   Subtract 1
 2p      Raise 2 to the power of that
^        XOR with the input
```
## If input `1` can fail: 4 bytes
```
¢Ån2
```
[Try it online!](https://ethproductions.github.io/japt/?v=1.4.5&code=osVuMg==&input=MzUw)
**Explanation**: get input binary (`¢`), slice off first char (`Å`), parse as binary back to a number (`n2`).
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 20 bytes
```
@(x)x-2^fix(log2(x))
```
[**Try it online!**](https://tio.run/##y08uSSxL/Z9mq6en999Bo0KzQtcoLi2zQiMnP90IyNX8n1hUlFiZVpqnkaajEG2oYKRgaKBgaAYkDRSMzMwVjE0NFEwNDGI1/wMA)
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 9 bytes
```
⊢-2*∘⌊2⍟⊢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24RHXYt0jbQedcx41NNl9Kh3PpAPlDi0QsFQwUjB0EDB0AxIGigYmZkrGJsaKJgaGAAA "APL (Dyalog Unicode) – Try It Online")
-1 byte thanks to Adam
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 7 bytes
```
{2b()b}
```
[Try it online!](https://tio.run/##S85KzP3/v9ooSUMzqfb/fwA "CJam – Try It Online")
Explanation:
```
{     }  Block:         267
 2b      Binary:        [1 0 0 0 0 1 0 1 1]
   (     Pop:           [0 0 0 0 1 0 1 1] 1
    )    Increment:     [0 0 0 0 1 0 1 1] 2
     b   Base convert:  11
```
Reuse the MSB (which is always 1) to avoid having to delete it; the equivalent without that trick would be `{2b1>2b}` or `{2b(;2b}`.
[Answer]
## [Retina](https://github.com/m-ender/retina), ~~15~~ 13 bytes
```
^(^1|\1\1)*1
```
[Try it online!](https://tio.run/##K0otycxL/K@qkaCnzaWi9T9OI86wJsYwxlBTy5Drv95/Qy4jLkMDLkMzIGnAZWRmzmVsasBlamAAAA "Retina – Try It Online")
Input and output [in unary](http://meta.codegolf.stackexchange.com/questions/5343/can-numeric-input-output-be-in-unary) (the test suite includes conversion from and to decimal for convenience).
### Explanation
This is quite easy to do in unary. All we want to do is delete the largest power of 2 from the input. We can match a power of 2 with some forward references. It's actually easier to match values of the form **2n-1**, so we'll do that and match one **1** separately:
```
^(^1|\1\1)*1
```
The group `1` either matches a single `1` at the beginning to kick things off, or it matches twice what it did on the last iteration. So it matches `1`, then `2`, then `4` and so on. Since these get added up, we're always one short of a power of 2, which we fix with the `1` at the end.
Due the trailing linefeed, the match is simply removed from the input.
]