[Question]
  [
An integer is binary-heavy if its binary representation contains more `1`s than `0`s while ignoring leading zeroes. For example 1 is binary-heavy, as its binary representation is simply `1`, however 4 is not binary heavy, as its binary representation is `100`. In the event of a tie (for example 2, with a binary representation of `10`), the number is not considered binary-heavy.
Given a positive integer as input, output a truthy value if it is binary-heavy, and a falsey value if it is not.
## Testcases
Format: `input -> binary -> output`
```
1          ->                                1 -> True
2          ->                               10 -> False
4          ->                              100 -> False
5          ->                              101 -> True
60         ->                           111100 -> True
316        ->                        100111100 -> True
632        ->                       1001111000 -> False
2147483647 ->  1111111111111111111111111111111 -> True
2147483648 -> 10000000000000000000000000000000 -> False
```
## Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so fewest bytes **in each language** wins
  
[Answer]
# x86 Machine Code, 15 14 bytes
```
F3 0F B8 C1 0F BD D1 03 C0 42 2B D0 D6 C3
```
This is a function using Microsoft's \_\_fastcall calling convention (first and only parameter in ecx, return value in eax, callee is allowed to clobber edx), though it can trivially be modified for other calling conventions that pass arguments in registers.
It returns 255 as truthy, and 0 as falsey.
It uses the undocumented (but widely supported) opcode `salc`.
Disassembly below:
```
;F3 0F B8 C1 
  popcnt eax, ecx ; Sets eax to number of bits set in ecx
;0F BD D1
  bsr edx, ecx    ; Sets edx to the index of the leading 1 bit of ecx
;03 C0
  add eax, eax
;42
  inc edx
;2B D0
  sub edx, eax
  ; At this point, 
  ;   edx = (index of highest bit set) + 1 - 2*(number of bits set)
  ; This is negative if and only if ecx was binary-heavy.
;D6
  salc           ; undocumented opcode. Sets al to 255 if carry flag 
                 ; is set, and to 0 otherwise. 
;C3
  ret
```
[Try it online!](https://tio.run/##XY/dTsIwGIbPdxVfZkhaKbo/B3HggXoXlCylP9BkdGbtSJFw687OYCSePd/fk/fjsx3nw3CnDW96IZfWCd0@7F@iyDrmNAfeGuuA71kXUMh1WmxgBTH1Kqc@UdRvF9Tz9MqCejFymL0l1BcZ9dkr9e@B38uwl8fVP7M2DtD9VhvWneq9ZMcTRr2xemekGIcY6po51@lt72RdI6SYdZw1DcYhxxgpGI@tFnBg2iAcnSOAWwE4aZ1dj6nPKclIQZ5ImZA8LUmZZyRLi3mxyMti/oeLSxUkqu0AjQK9SirQS6s/ZavQjw4/3lbrZIMrmE41DmcAH124Uiie9M8wEdTE5JpBbwjcfop@2xhX0WUYvrhq2M4Os0OefQM "C (gcc) – Try It Online")
Thanks to [Peter Cordes](https://codegolf.stackexchange.com/users/30206/peter-cordes) for suggesting replacing `lzcnt` with `bsr`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
Bo-SR
```
Yields non-empty output (truthy) or empty output (falsy).
[Try it online!](https://tio.run/##y0rNyan8/98pXzc46P/h9kdNayL//4821FEw0lEw0VEw1VEwM9BRMDY0AzKMgWJGhibmJhbGZibmSGyLWAA "Jelly – Try It Online")
### How it works
```
Bo-SR  Main link. Argument: n
B      Binary; convert n to base 2.
 o-    Compute the logical OR with -1, mapping 1 -> 1 and 0 -> -1.
   S   Take the sum s. We need to check if the sum is strictly positive.
    R  Range; yield [1, ..., s], which is non-empty iff s > 0.
```
[Answer]
# [Python 2](https://docs.python.org/2/), 35 bytes
```
lambda n:max('10',key=bin(n).count)
```
[Try it online!](https://tio.run/##HcxLCsIwFAXQuat4s7ZwkeZjWgpdiTpI1WDQ3pQSwa4@fmZndJYt3xN1CeOpPP08Xb1wmP27rlRb4XHbximyZrO/pBdzU0JahRIpRwUNiwNcC6McnNHQyna2N852f/7Un4edLGtkFkLCdyof "Python 2 – Try It Online")
### Old answer, 38 bytes
Outputs `0` as falsy and `-2` or `-1` as truthy
```
lambda n:~cmp(*map(bin(n).count,'10'))
```
[Try it online!](https://tio.run/##Hcy7DsIgFAbg3ac4W8H8MeUibZr0SaoDrSGSyIE0OLj46njZvukrr3rPrFuYL@3h03rzxNN7S0Ucky9ijSxYnrb85IpO9Z2ULeSdmCLToqBhcYbrYZSDMxpa2cGOxtnhz5/G63SgskeuxKDw/doH "Python 2 – Try It Online")
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 18 bytes
```
@(n)mode(de2bi(n))
```
TIO doesn't work since the communications toolbox is not included. It can be tested on [Octave-Online](http://octave-online.net/). 
### How this works:
`de2bi` converts a decimal number to a binary numeric vector, not a string as `dec2bin` does. 
`mode` returns the most frequent digit in the vector. It defaults to the lowest in case of a tie.
```
@(n)                % Anonymous function that takes a decimal number as input 'n'
    mode(        )  % Computes the most frequent digit in the vector inside the parentheses
         de2bi(n)   % Converts the number 'n' to a binary vector
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 3 bytes
```
BXM
```
[Try it online!](https://tio.run/##y00syfn/3ynC9/9/EwA "MATL – Try It Online")
I don't really know MATL, I just noticed that `mode` could work in [alephalpha's Octave answer](https://codegolf.stackexchange.com/a/132257/62346) and figured there was some equivalent in MATL.
```
B   ' binary array from input
 XM ' value appearing most.  On ties, 0 wins
```
[Answer]
## JavaScript (ES6), ~~36~~ 34 bytes
```
f=(n,x=0)=>n?f(n>>>1,x+n%2-.5):x>0
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 6 bytes
```
ḃọtᵐ>₁
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//@GO5oe7e0sebp1g96ip8f9/I0MTcxMLYzMT8/8A "Brachylog – Try It Online")
### Explanation
```
Example input: 13
ḃ        Base (default: binary): [1,1,0,1]
 ọ       Occurences:             [[1,3],[0,1]]
  tᵐ     Map Tail:               [3,1]
    >₁   Strictly decreasing list
```
Since `ḃ` will never unify its output with a list of digits with leading zeroes, we know that the occurences of `1` will always be first and the occurences of `0` will always be second after `ọ`.
[Answer]
# Mathematica, 22 bytes
Saved one byte thanks to [@MartinEnder](https://codegolf.stackexchange.com/users/8478/martin-ender) and [@JungHwanMin](https://codegolf.stackexchange.com/users/60043/junghwan-min).
```
#>#2&@@#~DigitCount~2&
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~44~~ (thanks @c-mcavoy) 40 bytes
```
lambda n:bin(n).count('0')<len(bin(n))/2
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSHPKikzTyNPUy85vzSvREPdQF3TJic1TwMiqqlv9L@gKBMokaZhqKnJBWMbIbFNkNimSGwzAySOsaEZspQxsgFGhibmJhbGZibm2AQtNDX/AwA "Python 3 – Try It Online")
[Answer]
# Regex (ECMAScript), 183 bytes
This was another interesting problem to solve with ECMA regex. The "obvious" way to handle this is to count the number of `1` bits and compare that to the total number of bits. But you can't directly count things in ECMAScript regex – the lack of persistent backreferences means that only one number may be modified in a loop, and at each step it can only be decreased.
This unary algorithm works as follows:
1. Take the square root of the largest power of 2 that fits into N, and take note of whether the square root was perfect or had to be rounded down. This will be used later.
2. In a loop, move each most-significant `1` bit to the least-significant position where there is a `0` bit. Each of these steps is a subtraction. At the end of the loop, the remaining number (as it would be represented in binary) is a string of `1`s with no `0`s. These operations are actually done in unary; it's only conceptually that they are being done in binary.
3. Compare this "binary string of `1`s" against the square root obtained earlier. If the square root had to be rounded down, use a doubled version of it. This ensures that the "binary string of `1`s" is required to have more than half as many binary digits as N in order for there to be a final match.
To obtain the square root, a variant of the multiplication algorithm briefly described in my [Rocco numbers regex post](https://codegolf.stackexchange.com/a/179420/17216) is used. To identify the least-significant `0` bit, the division algorithm briefly described in my [factorial numbers regex post](https://codegolf.stackexchange.com/a/178979/17216) is used. These are **spoilers**. So **do not read any further if you don't want some advanced unary regex magic spoiled for you**. If you do want to take a shot at figuring out this magic yourself, I highly recommend starting by solving some problems in the list of consecutively spoiler-tagged recommended problems in [this earlier post](https://codegolf.stackexchange.com/a/178889/17216), and trying to come up with the mathematical insights independently.
With no further ado, the regex:
`^(?=.*?(?!(x(xx)+)\1*$)(x)*?(x(x*))(?=(\4*)\5+$)\4*$\6)(?=(((?=(x(x+)(?=\10$))*(x*))(?!.*$\11)(?=(x*)(?=(x\12)*$)(?=\11+$)\11\12+$)(?=.*?(?!(x(xx)+)\14*$)\13(x*))\16)*))\7\4(.*$\3|\4)`
[Try it online!](https://tio.run/##XY/NbsIwEIRfBSIEu0kJGAKVSA2nHrj00B7rVrLABLfGiWwDKT/PTu2olapedu2Zz7PeD37gdmVk5fq2kmthdqX@FF83Q7U4tp5F8VhXACc6H8S3d1jQNF7Aog011DUmyEjcQajRi16JET0BLIuRTZIO@kOHTRsNQvFIEm6MDDuI8c@DduopQhrMK01jZIQhObAkJBHipaRR/v/AD/F13KQxMsXQ7lkGIXZ8YRne4sEJU1e@OCN1AZhaJVcCpnf9DDG3dJgft1IJAEWN4GsltQDENtV7pfBcUJXaSkkHvX4Pc7kB0LRIldCF2@J8dLlI@8SfQNKKGyuW2kHxOnxD/DXEX0PPyYLMgo1ua8pjtNQHruS6ZbguxKwVJSrflAZy@UBFLpME/cCojlIjKsEdSEx33K22YBDPttut/EoOwhYkr/bOOuOR/Hq9DfujyfQb "JavaScript (SpiderMonkey) – Try It Online")
```
# For the purposes of these comments, the input number = N.
^
# Take the floor square root of N
(?=
    .*?
    (?!(x(xx)+)\1*$)    # tail = the largest power of 2 less than tail
    (x)*?               # \3 = nonzero if we will need to round this square root
                        #      up to the next power of two
    (x(x*))             # \4 = potential square root; \5 = \4 - 1
    (?=
        (\4*)\5+$       # Iff \4*\4 == our number, then the first match here must result in \6==0
    )
    \4*$\6              # Test for divisibility by \4 and for \6==0 simultaneously
)
# Move all binary bits to be as least-significant as possible, e.g. 11001001 -> 1111
(?=
    (                                 # \7 = tool for making tail = the result of this move
        (
            (?=
                (x(x+)(?=\10$))*(x*)  # \11 = {divisor for getting the least-significant 0 bit}-1
            )
            (?!.*$\11)                # Exit the loop when \11==0
            (?=
                (x*)                  # \12 = floor((tail+1) / (\11+1)) - 1
                (?=(x\12)*$)          # \13 = \12+1
                (?=\11+$)
                \11\12+$
            )
            (?=
                .*?
                (?!(x(xx)+)\14*$)     # tail = the largest power of 2 less than tail
                \13                   # tail -= \13
                (x*)                  # \16 = tool to move the most-significant 1 bit to the
                                      # least-significant 0 bit available spot for it
            )
            \16
        )*
    )
)
\7                  # tail = the result of the move
\4                  # Assert that \4 is less than or equal to the result of the move
(
    .*$\3
|
    \4              # Double the value of \4 to compare against if \3 is non-empty,
                    # i.e. if we had an even number of total digits.
)
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~51~~ ~~48~~ ~~41~~ 40 bytes
```
i;f(n){for(i=0;n;n/=2)i+=n%2*2-1;n=i>0;}
```
[Try it online!](https://tio.run/##ldLBCoIwHAbwu08hgrBV4v5zmTDWsSfo2EWsxaBWWJ3EZ7etyDBX5nd134/PsSLaF0XTKC6RxpU8lUgJwjXXsaBYTYUO6YRGwLVQS8Lr5pgrjbBXeb7JuVT6KlEAfpto6Q8E7Jl1edv54Xajg5lEgDG3XzomHWECsWdW@eHyRqkLZf@jQBwoc6HzMWj/7@cuMyX/mWDyHNoxU@JCE0iHUcN9QU3dqN2ZCR0UW9Bxn6b/SVJgC5YlKVs8SPid3sh3/XUDcezkM1u1q37F8azavh1ee80d "C (gcc) – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~54~~ ~~53~~ 51 bytes
*-1 byte thanks to Max Lawnboy*
```
n=scan();d=floor(log2(n))+1;sum(n%/%2^(0:d)%%2)*2>d
```
reads from stdin; returns `TRUE` for binary heavy numbers. `d` is the number of binary digits; `sum(n%/%2^(0:d)%%2` computes the digit sum (i.e., number of ones).
[Try it online!](https://tio.run/##K/r/P8@2ODkxT0PTOsU2LSc/v0gjJz/dSCNPU1Pb0Lq4NFcjT1Vf1ShOw8AqRVNV1UhTy8gu5b@ZsdF/AA "R – Try It Online")
[Answer]
# [Kotlin](https://kotlinlang.org/), 50 bytes
```
{i:Int->i.toString(2).run{count{it>'0'}>length/2}}
```
Lambda of implicit type `(Int) -> Boolean`. Version 1.1 and higher only due to usage of `Int.toString(radix: Int)`.
Unfortunately TIO's Kotlin runtime seems to be 1.0.x, so here's a sad dog instead of a TIO link:
![](https://i.stack.imgur.com/uWkDL.png)
[Answer]
# x86\_64 machine code, ~~23~~ ~~22~~ 21 bytes
```
31 c0 89 fa 83 e2 01 8d 44 50 ff d1 ef 75 f3 f7 d8 c1 e8 1f c3
```
## Disassembled:
```
  # zero out eax
  xor  %eax, %eax
Loop:
  # copy input to edx
  mov  %edi, %edx
  # extract LSB(edx)
  and  $0x1, %edx
  # increment(1)/decrement(0) eax depending on that bit
  lea -1(%rax,%rdx,2), %eax
  # input >>= 1
  shr  %edi
  # if input != 0: repeat from Loop
  jnz  Loop
  # now `eax < 0` iff the input was not binary heavy,
  neg %eax
  # now `eax < 0` iff the input was binary heavy (which means the MSB is `1`)
  # set return value to MSB(eax)
  shr  $31, %eax
  ret
```
Thanks @Ruslan, @PeterCordes for `-1` byte!
[Try it online!](https://tio.run/##TVDRasMwDHz3V4iUgp16I2nSJCXdfmQuI7Wd1rA5w3GLQ@m3Z3K2wfxy0p10JyyfzlLO88pY@XFVGg6jV2Z4vrwSIgc7epCXzsFp8loOSr8d4QUSEYpcBJmJ0OxF6DvEQgS9FSFDvlEilKUIO9T7XgSFnEasd9jjXF8j1@B@5BFz1GSRtIQY6@GzM5bGonNnyZf0NI3NjcGdEICo2fa38Hr043LUHXIOWw4lhx2HKgMORV5hVSC5zcu6bIqqrOFf08CjjY794GCJNOiTtQgH2CNsNjES8FkUfqLMsV2YL4cLPU1OxnZuer/o7jbRtWI4uFbCJhwsBxpdacooY38fyKhlLFo8YrLT/uosZpLHPH8D "C (gcc) – Try It Online")
[Answer]
## Regex (ECMAScript), ~~85~~ ~~73~~ 71 bytes
```
^((?=(x*?)\2(\2{4})+$|(x*?)(\4\4xx)*$)(\2\4|(x*)\5\7\7(?=\4\7$\2)\B))*$
```
[Try it online!](https://tio.run/##TY1RT8IwFIX/Ci4k3Lu5IsuAhFlITHzghQd9tJo049JVS7t0FSbgb5/DxMS3k@87J@ddHmRTel2HtKn1lvze2Q/66jy3dBw8kXpsa4ATX47j7g1gxaGNVygyENk5/8ZkePkFIHKRty3Gwz5mIr9SFFMxF/N@08v5UGQoHrBvdPH4hCy45@C1VYCsMbokmN2mOWJxrLQhAMM9ya3RlgDxhttPY/CsuGFNbXSAUTrCQu8ALFfMkFWhwmV2uehmIzegeS19Q2sbQL3cvSL@Cfov7HKymiyuGkPl3TFa24M0ejvw0ipaDKLEFDvnodD3nAqdJNgfRm3EPNUkA2hkexnKCjxi6WzjDDHjVM@L726SZtPZDw "JavaScript (SpiderMonkey) – Try It Online")
*explanation by [Deadcode](https://codegolf.stackexchange.com/users/17216/deadcode)*
The earlier 73 byte version is explained below.
`^((?=(x*?)\2(\2{4})+$)\2|(?=(x*?)(\4\4xx)*$)(\4|\5(x*)\7\7(?=\4\7$)\B))+$`
Because of the limitations of ECMAScript regex, an effective tactic is often to transform the number one step at a time while keeping the required property invariant at every step. For example, to test for a perfect square or a power of 2, reduce the number in size while keeping it a square or power of 2 (respectively) at every step.
Here is what this solution does at every step:
If the rightmost bit is not a `1`, the rightmost `1` bit (if it is not the only `1` bit, i.e. if the current number is not a power of 2) is moved one step to the right, effectively changing a `10` to a `01` (for example, 1101**1**000 → 11010**1**00 → 110100**1**0 → 1101000**1**), which has no effect on the number's binary-heaviness. Otherwise, the rightmost `01` is deleted (for example 101110**01** → 101110, or 110**01**11 → 11011). This also has no effect on the number's heaviness, because the truth or falsehood of \$ones>zeroes\$ will not change if \$1\$ is subtracted from both; that is to say,
\$ones>zeroes⇔ones-1>zeroes-1\$
When these repeated steps can go no further, the end result will either be a contiguous string of `1` bits, which is heavy, and indicates that the original number was also heavy, or a power of 2, indicating that the original number was not heavy.
And of course, although these steps are described above in terms of typographic manipulations on the binary representation of the number, they're actually implemented as unary arithmetic.
```
# For these comments, N = the number to the right of the "cursor", a.k.a. "tail",
# and "rightmost" refers to the big-endian binary representation of N.
^
(                          # if N is even and not a power of 2:
    (?=(x*?)\2(\2{4})+$)   # \2 = smallest divisor of N/2 such that the quotient is
                           # odd and greater than 1; as such, it is guaranteed to be
                           # the largest power of 2 that divides N/2, iff N is not
                           # itself a power of 2 (using "+" instead of "*" is what
                           # prevents a match if N is a power of 2).
    \2                     # N = N - \2. This changes the rightmost "10" to a "01".
|                          # else (N is odd or a power of 2)
    (?=(x*?)(\4\4xx)*$)    # \4+1 = smallest divisor of N+1 such that the quotient is
                           # odd; as such, \4+1 is guaranteed to be the largest power
                           # of 2 that divides N+1. So, iff N is even, \4 will be 0.
                           # Another way of saying this: \4 = the string of
                           # contiguous 1 bits from the rightmost part of N.
                           # \5 = (\4+1) * 2 iff N+1 is not a power of 2, else
                           # \5 = unset (NPCG) (iff N+1 is a power of 2), but since
                           #   N==\4 iff this is the case, the loop will exit
                           #   immediately anyway, so an unset \5 will never be used.
    (
        \4                 # N = N - \4. If N==\4 before this, it was all 1 bits and
                           # therefore heavy, so the loop will exit and match. This
                           # would work as "\4$", and leaving out the "$" is a golf
                           # optimization. It still works without the "$" because if
                           # N is no longer heavy after having \4 subtracted from it,
                           # this will eventually result in a non-match which will
                           # then backtrack to a point where N was still heavy, at
                           # which point the following alternative will be tried.
    |
        # N = (N + \4 - 2) / 4. This removes the rightmost "01". As such, it removes
        # an equal number of 0 bits and 1 bits (one of each) and the heaviness of N
        # is invariant before and after. This fails to match if N is a power of 2,
        # and in fact causes the loop to reach a dead end in that case.
        \5                 # N = N - (\4+1)*2
        (x*)\7\7(?=\4\7$)  # N = (N - \4) / 4 + \4
        \B                 # Assert N > 0 (this would be the same as asserting N > 2
                           # before the above N = (N + \4 - 2) / 4 operation).
    )
)+
$       # This can only be a match if the loop was exited due to N==\4.
```
[Answer]
# [Perl 6](https://perl6.org), ~~32~~ 30 bytes
```
{[>] .base(2).comb.Bag{qw<1 0>}}
```
[Test it](https://tio.run/##ldHNToNAEAfw@z7FHIgFpZQF3DbBEjXRk8fGi3qgdDQkFNZd8COEJ/Pmi@EuVtp4KO3/tJmd38wSOIqMtZVEeGNOEpL1J5wkxQph3tYP0RM4y1ii6VlOUqyXznX8Ur@@X1Bwo6ZpVe9libKEOWRpjtK0vr8cybO0NCeP8hRG42gE6jDR9Zv7q7uQ6EULRULCsziHs86H5LkQm1HjCEwjzXlV2oZALmwDPzgmJa4sqAlAKkE/b9Nj2dDfq2NXC0nTUuijBg6E6p6FqJB4RzDq6p7bOJNIgsMddXfc@TFu@0zmHsaoyu@6jvmUDTMF/jHme4OsVzsf59FgGsx8Fkw7R/dn@w/@2EyX9Mh96df9AA "Perl 6 – Try It Online")
```
{[>] .polymod(2 xx*).Bag{1,0}}
```
[Test it](https://tio.run/##ldHBToNAEAbg@z7FHBoLlVIWcNuElKiJnjw2XtQDgdGQbGHDgqEhPJk3Xwx3sdLGQ2n/02Z2vpklCCw46yqJ8MnsOCDbHVzFeYKw7pqX8A1skfPdNk8MF@p6Ztr30UdDLadtO9V5W6IsYQ08zVAa5veXLQVPS2PxKmcwnYdTUIeFrj883z0FRK/ZKBIQwaMMrnsfkPe82I@ah2BM0kxUpTUpUBTWBGuBcYmJCQ0BSCXox@17TAuGe3XsawFpOwpD1MCRUN2zKSok7gWMOrrnMeISiX@@o86Ru7nEHZ7JnPMYVfld1zOPsnGmwD/GPHeUDero41zqL/2Vx/xl7@jpHP7BH1vpkh55KsO6Hw "Perl 6 – Try It Online")
## Expanded:
```
{      # bare block lambda with implicit parameter ｢$_｣
  [>]  # reduce the following with &infix:« > »
    .polymod(2 xx *) # turn into base 2 (reversed) (implicit method call on ｢$_｣)
    .Bag\            # put into a weighted Set
    { 1, 0 }         # key into that with 1 and 0
                     # (returns 2 element list that [>] will reduce)
}
```
[Answer]
# [Wise](https://github.com/Wheatwizard/Wise), ~~40~~ 39 bytes
```
::^?[:::^~-&[-~!-~-~?]!~-?|>]|:[>-?>?]|
```
[Try it online!](https://tio.run/##K88sTv3/38oqzj7aCkjW6apF69Yp6tbp1tnHKtbp2tfYxdZYRdvp2tvZx9b8///fyNDE3MTC2MzEAgA "Wise – Try It Online")
## Explanation
```
::^?                                      Put a zero on the bottom
    [                                     While
     :::^~-&                              Get the last bit
            [-~!-~-~?]!~-?|               Increment counter if 0 decrement if 1
                           >              Remove the last bit
                            ]|            End while
                              :[>-?>?]|   Get the sign
```
[Answer]
## Haskell, ~~41~~ 34
```
g 0=0
g n=g(div n 2)+(-1)^n
(<0).g
```
If `n` is odd, take a `-1` if it's even, take a `1`. Add a recursive call with `n/2` and stop if `n = 0`. If the result is less than `0` the number is binary-heavy.
[Try it online!](https://tio.run/##Rca9CoMwFAbQ3af4hg4JvUr@Gh3Mk0gLgdYY1Ito8fXj6JnOFI/5tyylJKigqgQOSXzzCYaRT1Fr@eFqDKJXsklljZkRsO2Z/3hgjRtGDJoMOXqRV2S1J28NGe1a11nv2rvdG@UC "Haskell – Try It Online")
Edit: @Ørjan Johansen found some shortcuts and saved 7 bytes. Thanks!
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~37~~ 34 bytes
```
.+
$*
+`(1+)\1
$1@
@1
1
+`.\b.
1+
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wX0@bS0WLSztBw1BbM8aQS8XQgcvBkMsQKKIXk6THxWWo/f@/IZcRlwmXKZeZAZexoRmXmbERAA "Retina – Try It Online") Link includes smaller test cases (the larger ones would probably run out of memory). Edit: Saved 3 bytes thanks to @MartinEnder. Explanation: The first stage converts from decimal to unary, and the next two stages convert from unary to binary (this is almost straight out of the unary arithmetic page on the Retina wiki, except that I'm using `@` instead of `0`). The third stage looks for pairs of dissimilar characters, which could be either `@1` or `1@`, and deletes them until none remain. The last stage then checks for remaining 1s.
[Answer]
# [R](https://www.r-project.org/), 43 bytes
```
max(which(B<-intToBits(scan())>0))/2<sum(B)
```
[Try it online!](https://tio.run/##K/r/PzexQqM8IzM5Q8PJRjczryQk3ymzpFijODkxT0NT085AU1PfyKa4NFfDSfO/saHZfwA "R – Try It Online")
```
             intToBits(scan())              # converts to bits
          B<-                 >0            # make logical and assign to B
max(which(                      ))/2        # get the length of the trimmed binary and halve
                                    <sum(B) # test against the sum of bits
```
[Answer]
# Julia, 22 bytes
```
x->2*x<4^count_ones(x)
```
[Answer]
# Pyth, ~~9~~ 7 bytes
```
ehc2S.B
```
[Try it here.](http://pyth.herokuapp.com/?code=ehc2S.B&input=2147483648&debug=0)
-2 thanks to [FryAmTheEggman](https://codegolf.stackexchange.com/users/31625/fryamtheeggman).
[Answer]
# R, ~~39~~ 37 bytes
```
sum(intToBits(x<-scan())>0)>2+log2(x)
```
This is a combination of the methods used by @MickyT and @Giuseppe, saving another few bytes.
`sum(intToBits(x) > 0)` counts the amount of `1` bits, and `2+log2(x)/2` is half of the total amount of bits, when rounded down. We don't have to round down because of the behaviour when the two values are equal.
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), ~~62~~, 49 bytes
Without LINQ.
EDIT: dana with a -13 byte golf changing the while to a recursive for and returning a bool instead of integer.
```
x=>{int j=0;for(;x>0;x/=2)j+=x%2*2-1;return j>0;}
```
[Try it online!](https://tio.run/##hc7PC4IwFAfwu3/FuwTaD9NpGqx5CToVBB06z7liYltsM4zwbzele@MdHrzPl/ceMyumNB9aI@QdLm9j@QN7rKHGwFmru6aPjwfwbMtGMDCW2rG9lKjgRIX0gwkBDq1kOyHtslSqKaACMnSk@IwTqEmEb0r7uCsi3K0JCuoF6WZojlYx1ty2WkI9Uj9g73c@3CtpVMPDqxaWH4XkfuXHQfDXkcNTh28cnkWOQBJnrhWJ60kUp3m6TbI0n4JeP9bwBQ "C# (.NET Core) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
Bµċ0<S
```
[Try it online!](https://tio.run/##y0rNyan8/9/p0NYj3QY2wf///zcyNDE3sTA2M7EAAA "Jelly – Try It Online")
[Answer]
# [Rust](https://www.rust-lang.org/), 30 bytes
```
|x:u64|x<1<<2*x.count_ones()-1
```
[Try it online!](https://tio.run/##TY3fCoIwHEbvfYovL2SLX9F0TSl7koiIcDCwGTphoHv2ZX8uOleHjw9OPw4uaovHzVjGMSVYaBsHfYqzP4xKzr4WdZ2v/fbejdZdO9sMjG9EPH6@uuuReRiL7CwIOUES9gS1IxRCLVIsWy5kKatCyfLPq8uv9@bZG@tau2LpFDCFlOAJmnnOv52QhPgC "Rust – Try It Online")
[Answer]
# [J](https://jsoftware.com), 12 bytes
```
(+/>-:@#)@#:
```
J executes verbs right-to-left, so let's start at the end and work our way towards the beginning.
**Explanation**
```
         #:       NB. Convert input to list of bits
       -:@#       NB. Half (-:) the (@) length (#)
          >       NB. Greater than 
         +/       NB. Sum (really plus (+) reduce (/)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 4 bytes
Returns 1 if binary heavy, 0 otherwise
```
b.MW
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/Sc83/P9/M2MjAA "05AB1E – Try It Online")
```
b            Convert to binary
 .M          Push a list of most frequent chars (contains 0 and 1 in case of a tie)
   W         Push the lowest value from the list
             Implicit output
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 4 bytes
```
bĊ↑h
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwiYsSK4oaRaCIsIiIsIjFcbjJcbjRcbjUiXQ==)
### Explained
```
bĊ↑h
b    # binary
 Ċ↑h # most values outputted, if tie then 0
```
[Answer]
# [Octave](https://www.gnu.org/software/octave/), 26 bytes
```
@(a)sum(2*dec2bin(a)-97)>0
```
[Try it online!](https://tio.run/##y08uSSxL/Z@mYKugp6f330EjUbO4NFfDSCslNdkoKTMPyNe1NNe0M/ifWFSUWJlWmqeRpqMQbaijYKSjYKKjYKqjYGago2BsaAZkGAPFjAxNzE0sjM1MzJHYFrGa/wE "Octave – Try It Online")
]