[Question]
  [
You will be given as **input** an integer `k` in the range from `-4503599627370496` (−252) to `4503599627370496` (252). As is [well known](https://stackoverflow.com/questions/3793838/which-is-the-first-integer-that-an-ieee-754-float-is-incapable-of-representing-e), integers in this range can be represented exactly as double-precision floating-point values.
You should **output** the [Hamming weight](https://en.wikipedia.org/wiki/Hamming_weight) (number of ones) of the encoding of `k` in [binary64 format](https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64). This uses 1 bit for the sign, 11 bits for the exponent (encoded with an offset), and 52 for the mantissa; see the above link for details.
As an **example**, number `22` is represented as
```
0 10000000011 0110000000000000000000000000000000000000000000000000
```
Since there are `5` ones, the output is `5`.
Note that endianness doesn't affect the result, so you can safely use your machine's actual internal representation of double-precision values to compute the output.
### Additional rules
* [Programs or functions](http://meta.codegolf.stackexchange.com/a/2422/36398) are allowed.
* Any [programming language](http://meta.codegolf.stackexchange.com/a/2073/36398) can be used.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden
* The input number will be in decimal. Other than that, input/output means and format are [flexible](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods) as usual.
* Shortest code in bytes wins.
### Test cases
```
22                ->   5
714               ->   6
0                 ->   0
1                 ->  10
4503599627370496  ->   5
4503599627370495  ->  55
1024              ->   3
-1024             ->   4
-4096             ->   5
1000000000        ->  16
-12345678         ->  16
```
  
[Answer]
# x86\_64 machine language (Linux), 16 bytes
```
0:       f2 48 0f 2a c7          cvtsi2sd %rdi,  %xmm0
5:       66 48 0f 7e c0          movq     %xmm0, %rax
a:       f3 48 0f b8 c0          popcnt   %rax,  %rax
f:       c3                      retq
```
Accepts a single 64-bit integer parameter in `RDI`, converts it to a floating-point value in `XMM0`, stores those bits back in `RAX`, and then computes the hamming weight of `RAX`, leaving the result in `RAX` so it can be returned to the caller.
Requires a processor that supports the `POPCNT` instruction, which would be Intel Nehalem, AMD Barcelona, and later microarchitectures.
To [Try it online!](https://tio.run/##jc5RS8MwEAfwZ/cpQoeQjFXSJE1apoIO97RvYHwIadMFayprhaD41Y0ZInswBe/p@N2fu9N5p3VYWqf7t6YF1@PU2OHqcLtYNq2xrgUGegQgtG6CKwT7wXUIdShi0IMbJ6AP6gi6x6ebTPodkZ5V0uOd9ORO@q2QnvOziYdoOObo2e6rH9vSbBPiFfCirDudAwp9LC5ej7E1MLtspMvWBhKC0OYvi4IlHSe1SCorMS3rmhNBBWY13/8nVaZTBSbph/L5CcM1n1n2WzMrCWUlF9Vp@hm@tOlVN4b8vfWtHieln78B "C (gcc) – Try It Online"), compile and run the following C program:
```
#include<stdio.h>
const char g[]="\xF2\x48\x0F\x2A\xC7\x66\x48\x0F\x7E\xC0\xF3\x48\x0F\xB8\xC0\xC3";
#define f(x) ((int(*)(long))g)(x)
int main(int a){
  printf("%d\n",f(22));
  printf("%d\n",f(714));
  printf("%d\n",f(0));
  printf("%d\n",f(1));
  printf("%d\n",f(4503599627370496L));
  printf("%d\n",f(4503599627370495L));
  printf("%d\n",f(1024));
  printf("%d\n",f(-1024));
  printf("%d\n",f(-4096));
  printf("%d\n",f(1000000000));
  printf("%d\n",f(-12345678));
}
```
Edit: Fixed segfault in TIO link.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~82~~ 68 bytes
9 bytes thanks to Neil.
evil floating point bit level hacking
```
s;f(long n){double d=n;n=*(long*)&d;for(s=0;n;n*=2)s+=n<0;return s;}
```
[Try it online!](https://tio.run/##jY5BDoIwFETXeooGo2lRTCkFJKWewCO40RaQBD@GwopwdgQTV5bEWU3eTCajvEKpcVOCqjqdodS0uqyPj/NoRI6rGgoEpNd1d68ypCUIkO4Hu2SnRV432EgqJuxKRsxeQkpFk7VdA8iIYSyhRc9bCXg2N9KvV69msjl2tvoKziHHjBEifnHscyunVupbKQ9pECZJxOIgpjyJLv@0QnvLp8x@yFtOOE2ihbGvFiZZwMMoPs3pML4B "C (gcc) – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 5 bytes
```
3Z%Bz
```
[Try it online!](https://tio.run/##y00syfn/3zhK1anq/38jIwA "MATL – Try It Online")
Exact transliteration of my MATLAB answer. Note that input and output are implicit. -2 bytes thanks to Luis Mendo.
```
3Z%   % Typecast: changes input (implicitly taken and converted to double) to uint64 without changing underlying bits
B     % Convert integer to array of 1s and 0s
z     % Count nonzero entries
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~72~~ 71 bytes
1 byte thanks to Lynn.
```
lambda n:n and(bin(1020+len(bin(abs(n))))+bin(abs(n))).count('1')-(n>0)
```
[Try it online!](https://tio.run/##XY7LCsIwFETX9iuya4qp3LwaW6g/oi7SFxbqbWniwq@PUVHEWQzMYWBmufvLjDIM9SlM9tp0lmCFxGJHmxEpBwHbqcdXsI2jmEVtf9OunW/oacrTLKd4gCz43vnWut6RmhyFYIYrBowzpUHqsiyEkQZUWfwDzeKcYvnbFcQGh48iFlLpwuzPSTLMK0EyIvlOVclmWcf4Y3ieCg8 "Python 3 – Try It Online")
### Explanation
The binary64 format consists of three components:
* the first bit is the sign bit, which is `1` if the number is negative
* the next 11 bits store the exponent with 1023 added
* the next 52 bits store the significand, or the mantissa.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 47 bytes
```
f(double n){n=__builtin_popcountl(*(long*)&n);}
```
This isn't portable; it was tested with gcc 7.1.1 on x86\_64 running Linux, without compiler flags.
[Try it online!](https://tio.run/##ZY/RioMwEEWfzVcMhS6JjWyMUStu90faIm3UEkgTqfGl4re7EbZU6LxcOHO5c0dGNynnucW1Ha66AUNGc6iq66C0U6bqbCftYJzGIdbW3ELyZUg5zco4uF@UwQSNKFg24JreVfLSN/3xDAcYOaeQx4ICoxBTEClL0qLIeJ7kTBTZB0m9jXHvj/5FsMUVs9csG56INMv3U4lQ0NoH4KWI8udY6eUHevVsbIvfXQh8v2C4ot692xEUBN3DJ7R4s40zXUP0C1ten8yGrt9RZwrrTA8IKdE0/wE "C (gcc) – Try It Online")
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), 92 bytes
```
int f(long n){int s=0;for(n=Double.doubleToLongBits((double)n);n!=0;n>>>=1)s+=n&1;return s;}
```
[Try it online!](https://tio.run/##XZDNboMwEITP8BTupbIFQUD4KaLkUPVIT@kNcXDBUKewRthJVSGePbWTppVqS17tp5FnZw/0RDdiYnBoP87T8W3gDWoGKiV6oRyWMweFOjwI6BGQxXSy8PNOzBiKZ6H1zGsv5VWUWvTElcT4SgiQHO60Gna7XREQ6RRwH@QzU8cZkMzXm59UVOlyErxFo3bFezVz6Kuazr0ki21d7BWTqqGSyapGBQL2iQyu6iUM3TSIXN8N3Cj2t3GWJWG6Tf0oS8r/JC7dwA8jd3N9Iz9LNLgdjcNtFCfpw5rbllkAGn@8TIOJpia6WQPXwfjj71DewKBX7zl3HDOxtf@Sio2eOCpv0mHUAHj0OvwXgtfEfLfa@p6/AQ "Java (OpenJDK 8) – Try It Online")
[Answer]
# C (gcc), 63 bytes
```
f(double d){long s=0,n=*(long*)&d;for(;n;n*=2)s+=n<0;return s;}
```
This solution is based on @LeakyNun's answer, but because he doesn't want to improve his own answer, I'm posting here more golfed version.
[Try it online](https://tio.run/##jY5NDoIwFITXeooGo2kRTCktSAqewCO4wRawCT4MPyvC2VEWriyJbzXvm8lklF8pNe8MqHrQBUq7Xpvm9LjMJdbNcK8LpMlYN1ChLqMeZC5eHpcctCybFkuQ4GaMdMcMUirboh9aQJ2cZgM9euYG8CJyMm43r/YjS@zs9Q0cr8SMESJ/cRxwK6dWGlgpFzQUSRKxOIwpT6LrPylhTwWU2Qf56w6nSbRS9r2VShZyEcXnxZ3mNw)
[Answer]
# C#, ~~81~~ ~~70~~ 68 bytes
```
d=>{unsafe{long l=*(long*)&d,s=0;for(;l!=0;l*=2)s-=l>>63;return s;}}
```
*Save 11 bytes thanks to @Leaky Nun.*  
*Saved 2 bytes thanks to @Neil.*
[Try it online!](https://tio.run/##nY/LSsUwEIb3fYq4a@W0pGnaWmK6UBEEBVHBdWxTCaSJJOkBOfTZay94OSAY/BfDTOab/DONjXut9KRYz@0bazh4fLeO98EhALMayawF92u@vSyyjjnRgL0WLbhjQoXRV@sbWnQ9qOa81cOL5DsgtXqtQQfo1NL6sFRA0s0tuRDuUqs9N46b5GodeNI3yhV47tiwjXaWQtJpExJ5MmfylKLIxlTWdZERw91gFLBknMiR/1ExG1gtefJshOO3QvGwCxGKIvInVabYB4M@UOoD4RxmeVUVqMxKiKviHzO51zIQeV0We4MY@m2bwk/5@aMM50V5tsC/0g@ctSv847cx2OI4fQA "C# (Mono) – Try It Online") Uses `System.BitConverter.DoubleToInt64Bits` instead of the `unsafe` code as I couldn't get TIO to work with it.
Full/Formatted Version:
```
namespace System
{
    class P
    {
        static void Main()
        {
            Func<double, long> f = d =>
            {
                unsafe
                {
                    long l = *(long*)&d, s = 0;
                    for (; l != 0; l *= 2)
                        s -= l >> 63;
                    return s;
                }
            };
            Console.WriteLine(f(22));
            Console.WriteLine(f(714));
            Console.WriteLine(f(0));
            Console.WriteLine(f(1));
            Console.WriteLine(f(4503599627370496));
            Console.WriteLine(f(4503599627370495));
            Console.WriteLine(f(1024));
            Console.WriteLine(f(-1024));
            Console.WriteLine(f(-4096));
            Console.WriteLine(f(1000000000));
            Console.WriteLine(f(-12345678));
            Console.ReadLine();
        }
    }
}
```
[Answer]
# [Python 2](https://docs.python.org/2/), 69 bytes
-12 bytes, thanks to @ASCII-only
```
lambda n:bin(*unpack('Q',pack('d',n))).count('1')
from struct import*
```
[Try it online!](https://tio.run/##XY2xCsIwFEV3vyJbkvIqSZo0tqBf0MVZHdpKMWhfQkwHvz4Wiot3OFwOF274pIdHlbvjNb/6ebj3BNvBISsWDP34ZPRMYSt3Csg5349@wcSopHw3RT@Td4rLmIibg4@pyJOPxBGH5KIUWKlBgARtRGWapla2skI39b8wIIXSUG7UYl1I8cuqVaVNbQ@3loTocD0DWp4odMzx/AU "Python 2 – Try It Online")
[Answer]
# x86-64 machine code, 12 bytes for `int64_t` input
# 6 bytes for `double` input
Requires the [`popcnt` ISA extension](http://felixcloutier.com/x86/POPCNT.html) (`CPUID.01H:ECX.POPCNT [Bit 23] = 1`).
(Or 13 bytes if modifying the arg in-place requires writing all 64-bits, instead of leaving garbage in the upper 32. I think it's reasonable to argue that the caller would probably only want to load the low 32b anyway, and x86 zero-extends from 32 to 64 implicitly with every 32-bit operation. 
 Still, it does stop the caller from doing `add rbx, [rdi]` or something.)
x87 instructions are shorter than the more obvious SSE2 `cvtsi2sd`/`movq` (used in [@ceilingcat's answer](https://codegolf.stackexchange.com/questions/136349/float-754-to-hamming/136360#136360)), and a `[reg]` addressing mode is the same size as a `reg`: just a mod/rm byte.
The trick was to come up with a way to have the value passed in memory, without needing too many bytes for addressing modes. (e.g. passing on the stack isn't that great.) Fortunately, [the rules allow read/write args, or separate output args](https://codegolf.meta.stackexchange.com/a/4942/30206), so I can just get the caller to pass me a pointer to memory I'm allowed to write.
Callable from C with the signature: `void popc_double(int64_t *in_out);` Only the low 32b of the result is valid, which is maybe weird for C but natural for asm. (Fixing this requires a REX prefix on the final store (`mov [rdi], rax`), so one more byte.) On Windows, change `rdi` to `rdx`, since Windows doesn't use the x86-64 System V ABI.
NASM listing. The TIO link has the source code without the disassembly.
```
  1  addr    machine      global popcnt_double_outarg
  2          code         popcnt_double_outarg:
  3                           ;; normal x86-64 ABI, or x32: void pcd(int64_t *in_out)
  4 00000000 DF2F             fild qword  [rdi]    ; int64_t -> st0
  5 00000002 DD1F             fstp qword  [rdi]    ; store binary64, using retval as scratch space.
  6 00000004 F3480FB807       popcnt rax, [rdi]
  7 00000009 8907             mov    [rdi], eax    ; update only the low 32b of the in/out arg
  8 0000000B C3               ret
    # ends at 0x0C = 12 bytes
```
[**Try it online!**](https://tio.run/##dVLRjtsgEHzPV8xjUjm9NHF8l4tUqVVfKvUPqsoCQxx0DlAWEvvrU8Cyrz1d/YI93pmd2YURyQvvhrVmdLnf285w1sEa22hfCxN4J2sTPHPt4j3weYH4HI/od1sYB23cJfL7p2pdlfjy9fszrkYJ2EYslfZVWXt8UDqxV5l6Up3A75txAvjphPqV9TDVrj@D/GasJG/fqSRvnARXmrmhKgsEUrqFk/4afTACNY755gyyrJEfs9IYBI71xaiU0Yu5piMDBSTrR/1gBfMSRncD/FmiMzfsthzmlD@VfohZkOaT6mPfaYY1xQH5xXiMc5rb5NZYf5rR419wud/s9odDtX3cPW7Kwz7beANWi5lqA50T800HoQo4sjPasO4/e31VMjYTJ0@4qchppUfLHGdtSptDB2uli1MowGN2GqiWvfJQbVy/JMTXpXWmkUTIP@IIfIg4zRPkg5erfx3LFL7azGCUzZ5nN1OfJZYh3o@n2q9igrTmV6V4E38Y8zIZ/SZ5aOEZxylezoRkP40R8v4H "Assembly (nasm, x64, Linux) – Try It Online") Includes a `_start` test program that passes it a value and exits with exit status = popcnt return value. (Open the "debug" tab to see it.)
Passing separate input/output pointers would also work (rdi and rsi in the x86-64 SystemV ABI), but then we can't reasonably destroy the 64-bit input or as easily justify needing a 64-bit output buffer while only writing the low 32b.
If we do want to argue that we can take a pointer to the input integer and destroy it, while returning output in `rax`, then simply omit the `mov [rdi], eax` from `popcnt_double_outarg`, bringing it down to 10 bytes.
---
## Alternative without silly calling-convention tricks, 14 bytes
use the stack as scratch space, with `push` to get it there. Use `push`/`pop` to copy registers in 2 bytes instead of 3 for `mov rdi, rsp`. (`[rsp]` always needs a SIB byte, so it's worth spending 2 bytes to copy `rsp` before three instructions that use it.)
Call from C with this signature: `int popcnt_double_push(int64_t);`
```
 11                               global popcnt_double_push
 12                               popcnt_double_push:
 13 00000040 57                       push   rdi         ; put the input arg on the stack (still in binary integer format)
 14 00000041 54                       push   rsp         ; pushes the old value (rsp updates after the store).
 15 00000042 5A                       pop    rdx         ; mov      rdx, rsp
 16 00000043 DF2A                     fild   qword [rdx]
 17 00000045 DD1A                     fstp   qword [rdx]
 18 00000047 F3480FB802               popcnt rax,  [rdx]
 19 0000004C 5F                       pop    rdi         ; rebalance the stack
 20 0000004D C3                       ret
    next byte is 0x4E, so size = 14 bytes.
```
---
# Accepting input in `double` format
The question just says it's an integer in a certain range, not that it has to be in a base2 binary integer representation. Accepting `double` input means there's no point in using x87 anymore. (Unless you use a custom calling convention where `double`s are passed in x87 registers. Then store to the red-zone below the stack, and popcnt from there.)
**11 bytes:**
```
 57 00000110 66480F7EC0               movq    rax, xmm0
 58 00000115 F3480FB8C0               popcnt  rax, rax
 59 0000011A C3                       ret
```
But we can use the same pass-by-reference trick as before to make a 6-byte version: `int pcd(const double&d);`
```
 58 00000110 F3480FB807               popcnt  rax, [rdi]
 59 00000115 C3                       ret
```
**6 bytes**.
[Answer]
# [Perl 5](https://www.perl.org/), ~~33~~ 32 + 1 (-p) = ~~34~~ 33 bytes
*Saved 1 byte thanks to hobbs*
```
$_=(unpack"B*",pack d,$_)=~y/1//
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3lajNK8gMTlbyUlLSQfEUEjRUYnXtK2r1DfU1///38joX35BSWZ@XvF/3QIA "Perl 5 – Try It Online")
[Answer]
## JavaScript (ES6), ~~81~~ ~~80~~ ~~77~~ 76 bytes
```
f=
n=>new Uint8Array(Float64Array.of(n).buffer).map(g=i=>i&&g(i&i-1,x++),x=0)|x
```
```
<input oninput=o.textContent=f(this.value)><pre id=o>0
```
Edit: Saved 1 byte thanks to @Arnauld. Saved 3 bytes thanks to @DocMax. Saved 1 byte thanks to @l4m2.
[Answer]
## MATLAB, 36 bytes
```
@(n)nnz(de2bi(typecast(n,'uint64')))
```
Using the fact that `de2bi` is not only shorter than `dec2bin`, but also provides a result in ones and zeroes rather than ASCII 48, 49.
[Answer]
# Java (64, 61, 41 bytes)
Completely straightforward using the standard library (Java SE 5+):
```
int f(long n){return Long.[bitCount](https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html#bitCount-long-)(Double.[doubleToLongBits](https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#doubleToLongBits-double-)(n));}
```
Contribution by Kevin Cruijssen (Java SE 5+):
```
int f(Long n){return n.bitCount(Double.doubleToLongBits(n));}
```
Contribution by Kevin Cruijssen (Java SE 8+, lambda function):
```
n->n.bitCount(Double.doubleToLongBits(n))
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~79~~76 bytes
```
n=>n&&((g=n=>t=n.toString(2))(n)+g(t.length*2-(n<0)+2044)).split`1`.length-2
```
[Try it online!](https://tio.run/##hY5BDoIwEEX3HoRMJTTt0FJJrJfwAhDEimmmBBqvX1nowpTEWU3en7w/z/7Vr8MyzbGicBvT3SayFyoKAGe3LVriMVzjMpEDZAyIlQ4i9yO5@DhiBXQWrEShFGN8nf0UO9l94grTEGgNfuQ@OLgDbobDLzJSZUxkRGYkNyktat22DZraCNU2/w503iIwf6bap0rsNEjxnR0N1ko35sRYegM "JavaScript (Node.js) – Try It Online")
~~First answer not relying on cast?~~ At least [this](https://codegolf.stackexchange.com/a/136411/) is earlier
[Answer]
Just to try a different, safer-than-[TheLethalCoder's](https://codegolf.stackexchange.com/a/136359/70347) approach, I came up with this (it's a pity C# has such long method names):
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 76+13 bytes
```
d=>Convert.ToString(BitConverter.DoubleToInt64Bits(d),2).Split('1').Length-1
```
[Try it online!](https://tio.run/##nY/BS8MwFMbv/StyWwJrSdO0tcztoCIIE4QOPIiHmGY10CWSvA5E/NtrVzfnzeB3eIeX3/e9L9LH0jo19F6bFtXvHtRuEUVolOyE9@jB2daJ3bT5mOZBHgRoifZWN@heaIM9uDHg6RkJ13ryw50dB932Rl42tn/p1BxpAyu0RctoaJara2v2ykGysfUUhK80HHfKJTeTZWPvDBR8fPG4IXNGkvqt04Bn6Ywka2VaeI3T4Vj@pDHE204lj06DWmuj8BYzRsjiT6pMeQhGQ6A0BOI5zfKqKliZlZRXxT88eVAZyoJ@FgeDnIa1TelJYfdZxvOivPgNf0bfc/gC "C# (.NET Core) – Try It Online")
Byte count includes 13 bytes for `using System;`. First I need to convert the `double` to a `long` that has the same binary representation, then I can convert it to a binary `string`, and then I count the `1`s just by splitting the string and counting the substrings minus 1.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 19 bytes
```
AB©L+⁽¡ßB;®ċ1_>0$a@
```
[Try it online!](https://tio.run/##y0rNyan8/9/R6dBKH@1HjXsPLTw838n60Loj3YbxdgYqiQ7/D7c/alrz/3@0kZGOuaGJjoGOoY6JqYGxqaWlmZG5sbmBiaUZuoCpjqGBkYmOLoQ0MQCqMDSAAaCwkbGJqZm5RSwA "Jelly – Try It Online")
[Answer]
# dc, 79 bytes
```
[pq]su[-1r]st0dsb?dd0=u0>tsa[1+]ss[la2%1=slb1+sblad2/sa1<r]dsrxlb1022+sa0lrx+1-
```
Output is left on top of the stack.  
I'll add an explanation later.
[Try it online!](https://tio.run/##Dcg5DoAwDATA11BFCNucBcdDogg5uEwBWZD4fWDKsaMUf14Bj685B9xkiJsZLQ@tN9SzC4BPKhUvSJEdYlKTBspzDob8/kkiDkopv47rs5Sdpe36YZw@)
Note that negative numbers are preceded by `_`, not `-`.
[Answer]
# [Groovy (with Parrot parser)](https://github.com/danielsun1106/groovy-parser), 46 bytes
```
f=n->Long.bitCount(Double.doubleToLongBits(n))
```
[Answer]
# C, 67 bytes
```
int i;g(char*v){int j=v[i/8]&1<<i%8;return!!j+(++i<64?g(v):(i=0));}
```
control code and results
```
#define R     return
#define u32 unsigned
#define F        for
#define P     printf
int main()
{/*           5   6 0 10                5               55    3      4       16*/
 double v[]={22,714,0,1 ,4503599627370496,4503599627370495,1024, -1024, -12345678};
 int i; 
 F(i=0;i<9;++i)
     P("%f = %d\n", v[i], g(&v[i]));
 R 0;
}
>tri4
22.000000 = 5
714.000000 = 6
0.000000 = 0
1.000000 = 10
4503599627370496.000000 = 5
4503599627370495.000000 = 55
1024.000000 = 3
-1024.000000 = 4
-12345678.000000 = 16
```
[Answer]
# Erlang 55 bytes
```
fun(X)->length([Y||<<Y:1>><=<<X:64/float>>,Y=:=1])end.
```
An anonymous function that counts all the `1`s in a number encoded as a 64 bit float.
references:
* <http://erlang.org/doc/programming_examples/bit_syntax.html>
* <http://erlang.org/doc/programming_examples/list_comprehensions.html>
[Answer]
# [Husk](https://github.com/barbuz/Husk), 20 bytes
```
&->0±¹ΣS+ȯḋ+1022Lḋa¹
```
[Try it online!](https://tio.run/##yygtzv6fm18erPOoqfG/mq6dwaGNh3aeWxysfWL9wx3d2oYGRkY@QEbioZ3///@PNjLSMTc00THQMdQxMTUwNrW0NDMyNzY3MLE0Qxcw1QHqNdHRhZAmBkAVhgYwABQ2MjYxNTO3iAUA "Husk – Try It Online") A port of [Leaky Nun's Python 3 answer](https://codegolf.stackexchange.com/a/136411/).
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 17 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ĀiÄbDgŽ42+b«1¢Id-
```
Port of [*@LeakyNun*'s Python 3 answer](https://codegolf.stackexchange.com/a/136411/52210), so make sure to upvote him as well!
[Try it online](https://tio.run/##yy9OTMpM/f//SEPm4ZYkl/Sje02MtJMOrTY8tMgzRff/f10TA0szAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfaXL/yMNmYdbklzSj@41MdJOOrTa8NCiyhTd/7U6/6ONjHTMDU10DHQMdUxMDYxNLS3NjMyNzQ1MLM3QBUx1DA2MTHR0IaSJAVCFoQEMAIWNjE1MzcwtYgE).
**Explanation:**
```
Āi                 # If the (implicit) input-integer is NOT 0:
  Ä                #  Take the absolute value of the (implicit) input-integer
   b               #  Convert it to binary
    Dg             #  Duplicate it, then pop and push its length
      Ž42+         #  Add compressed integer 1022 to this length
          b        #  Convert it to binary as well
           «       #  Merge the two binary-strings together
            1¢     #  Count the amount of 1s in this string
              Id   #  Check that the input-integer is non-negative (1 if >=0; 0 if <0)
                -  #  Subtract that from the count
                   #  (after which it is output implicitly as result)
                   # (implicit else: output the implicit input, which is 0)
```
[See this 05AB1E tip of mine (section *How to compress large integers?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `Ž42` is `1022`.
[Answer]
# [Rust](https://www.rust-lang.org/), 27 bytes
```
|n|n.to_bits().count_ones()
```
[Try it online!](https://tio.run/##KyotLvmflqeQm5iZp6FZrcCloJCTWqKQZpWWp5FmZqKpaxdvq/C/Jq8mT68kPz4ps6RYQ1MvOb80ryQ@Py8VyPlvDdSSWFycWlQSn1qoqGGsk6ZhaGBkoqepiSZjApTRxS5lAJQyAAvX/gcA "Rust – Try It Online")
An anonymous function that takes in an f64 and outputs a u32. The `to_bits` function reinterprets the bits of an f64 into a u64, where I can use the convenient `count_ones` function to trivialize the problem.
]