text:
Binning in time
The task in this challenge is to put elements of an array into time bins. The input will be a non-decreasing array of positive integers representing the time of events, and an integer which represents the size of each bin.  Let us start with an example. We call the input array A and the output array O.
`A = [1,1,1,2,7,10]` and `bin_size = 2`.

`O = [4,0,0,1,1]`.

Why? With a bin_size = 2, we'll have the following intervals: (0,2], (2,4], (4,6], (6,8], (8,10], where four items (1,1,1,2) are within the first interval (0,2], none in the second and third intervals, one 7 in the interval (6,8], and one 10 in the interval (8,10].
Your code should consider every interval of length bin_size starting from 0 and count how many numbers in A there are in each.  You should always include the right hand end of an interval in a bin so in the example above 2 is included in the count of 4.  Your code should run in linear time in the sum of the lengths of the input and output.
More examples:
`A = [1,2,7,12,15]`  and `bin_size = 5`.

`O = [2, 1, 2]`.

`A = [1,2,7,12,15]`  and `bin_size = 3`.

`O = [2,0,1,1,1]`.

You can assume that input and output can be given in any format you find convenient. You can use any languages and libraries you like.

Are outputs with trailing 0s allowed? So returning [2,0,1,1,1,0] instead of [2,0,1,1,1]?

No trailing zeros please.

What about situations where max array value is not a multiple of bin_size, should we really handle these? It seems that most answers do, but if so, it would be nice to add a test case for this scenario to prevent confusion.

@KirillL. Yes they should be handled too.

Can you please explain, in your first example, why is the value 2 not in the second interval (2,4]

@GPS The righthand end is included but not the left hand end.

So, (a,b] includes b but not a for all a<b. If input array has a 0, which bin does that get into, or in other words, is 0 a positive integer in context of this problem?

@GPS 0 is not a positive integer.  This isn’t an accident :)

R, 48 bytes
function(n,s)table(cut(n,0:ceiling(max(n)/s)*s))

Try it online!
Once again, table and cutting to a factor do the trick for the binning. Outputs a named vector where the names are the intervals, in interval notation, for instance, (0,5].
EDIT: Revert back to earlier version that works when s doesn't divide n.

I really don't R, but on TIO this appears to output a format you [most likely do not] find convenient without the table part.

@someone that's exactly why it's there. cut splits the vector into factors with levels given by the intervals, and table counts the occurrences of each unique value in its input.

I was suggesting to remove the table part to save 7 bytes and make your output format less good. According to the specs, you can output in any format you find convenient.

@someone ah, I see, I misunderstood your comment. No, I think that wouldn't be valid since we need the counts of each bin.

Not fully tested, but I think you can save a couple bytes reaplacing 0:ceiling(max(n)/s)*s with seq(0,max(n)+s-1,s). It works at least for the two samples in the question.

@Gregor Hmm if that does work 1:max(n/s+1)*s-s is another improvement since the two are equivalent

Octave, 36 bytes
@(A,b)histc(A,1:b:A(end)+b)(1:end-1)

Try it online!
Out hunting Easter eggs and making a bonfire. I'll add an explanation when I have the time.

Python 2, 62 bytes
I,s=input()
B=[0]*(~-I[-1]/s+1)
for i in I:B[~-i/s]+=1
print B

Try it online!

First of all: nice answer, I've already +1-ed it (and created a port in Java, because it's quite a bit shorter than what I had). Trailing zeroes aren't allowed however (just asked OP), so I[-1]/s+1 should be ~-I[-1]/s+1 instead.

@KevinCruijssen Thanks for notice!

Perl 5 -a -i, 32 28 bytes
Give count after the -i option. Give each input element on a separate line on STDIN
$G[~-$_/$^I]--}{say-$_ for@G

Try it online!

This is impressive.

05AB1E, 18 bytes
θs/Å0¹vDyI/î<©è>®ǝ

Try it online!

I don't know 05AB1E that well, but this seems to call A.count max(A), so run time isn't linear in len(A) + len(O). Is that correct or did I get something wrong?

@Dennis count would be O(max(A)*max(A))... so it's quadratic on the maximum of A... OP specified it had to be linear in terms of... what exactly?

@MagicOctopusUrn Your code should run in linear time in the sum of the lengths of the input and output, according to the latest revision.

@Dennis that seems rather arbitrary.

@MagicOctopusUrn It’s the only sensible definition for linear time for this question I think.

APL+WIN, 23 bytes
Prompts for screen input of bins then vector of integers:
+⌿<\v∘.≤b×⍳⌈⌈/(v←⎕)÷b←⎕

Explanation:
⎕ Prompt for input

⌈⌈/(v←⎕)÷b←⎕ divide the integers by bin size, take maximum and round up for number of bins

b×⍳ take number of bins from previous step and create a vector of bin upper boundaries

v∘.≤ apply outer product to generate boolean matrix where elements of vector ≤ boundaries

<\ switch off all 1's after first 1 in each row to filter multiple bin allocations

+⌿ sum columns for the result

Java 8, 75 bytes
a->b->{var r=new int[~-a[a.length-1]/b+1];for(int i:a)r[~-i/b]++;return r;}

Port of @DeadPossum's Python 2 answer, so make sure to upvote his answer!
Explanation:
Try it online.
a->b->{          // Method with integer-array and integer parameters and no return-type
  var r=new int[~-a[a.length-1]/b+1];
                 //  Result integer-array of size `((last_item-1)/bin_length)+1`
  for(int i:a)   //  Loop over the input-array
    r[~-i/b]++;  //   Increase the value at index `(i+1)/bin_length` by 1
  return r;}     //  Return the result-array

C++ (gcc), 90 83 bytes
auto f(auto i,int s){typeof i j;for(auto v:i)--v/=s,j.resize(v+1),j[v]++;return j;}

Try it online!

JavaScript (ES6), 60 bytes / O(len(a)+max(a)/n)
Saved 5 bytes thanks to @Neil
Takes input in currying syntax (a)(n).
a=>n=>[...a.map(x=>o[x=~-x/n|0]=-~o[x],o=[])&&o].map(n=>~~n)

Try it online!
Or just 43 bytes / O(len(a)) if empty elements are allowed.

[...o].map(n=>n|0) gets the first output from the second solution in fewer bytes.

@Neil Not sure why I went for something so convoluted. :-/

Ruby, 60 bytes
->a,b{(b...a[-1]+b).step(b).map{|i|a.count{|n|n<=i&&n>i-b}}}

Try it online!

Haskell, 63 75 70 bytes
l!n=l#[n,2*n..]
[]#_=[]
l#(b:i)|h<-length$takeWhile(<=b)l=h:drop h l#i

Whoops, this shorter one isn't linear but quadratic;

l!n=l#[n,2*n..]
[]#_=[]
l#(b:i)=sum[1|a<-l,a<=b]:[a|a<-l,a>b]#i

Try it online!

C (gcc), 102 90 89 86 bytes
#define P!printf("%d ",k)
i,j,k;f(s){for(i=s;~scanf("%d",&j);k++)for(;j>i;i+=s)k=P;P;}

Try it online!
Thanks to Kevin Cruijssen for slashing off 12 bytes, and ceilingcat for another 4 bytes!

90 bytes by using for-loops, removing the int, and changing ==1 to >0.

You're welcome. Btw, just a note, it's currently invalid (just like my now deleted Java answer was). It's required to run in O(n) time, so you can't have any nested for-loops.. (Your C++ answer seems fine, though. So I've +1-ed that one. :) )

It is still O(n). The inner loop will always print a value, and we only print (max value + 1) / binsize values in total.

Hmm, but isn't the outer loop already O(n) by looping over the input items. Even if the inner loop would only loop 2 times it's already above O(n). Or am I misunderstanding something.. I must admit O-times aren't really my expertise..

But the inner loop doesn't iterate over all input elements, it only iterates over however many output values it needs to print to "catch up" to the position corresponding to the latest input element. If the input vector consists of lots of duplicates or values that differ less than the bin size, the inner loop will not perform any iterations at all. On the other hand, if the input vector is very sparse, then the inner loop will perform more iterations, printing 0's. So to be correct, the code runs in O ((number of input elements) + (last element / bin size)) time. This is still linear.

Ah, you're completely right. My original Java answer that I now edited was also O(n + last_element/bin_size). When I read "linear time" and looked it up I saw O(n) and figured they were the same. O(n + last_element/bin_size) is indeed still lineair, just another linear than O(n). Thanks for the explanation!

Pyth, 23 22 bytes
Jm/tdeQhQK*]ZheJhXRK1J

Try it here
Jm/tdeQhQK*]ZheJhXRK1J
Jm/tdeQhQ                 Find the bin for each time and save them as J.
         K*]ZheJ          Create empty bins.
                 XRK1J    Increment the bins for each time within them.
                h         Take the first (because mapping returned copies).

Ruby, 53 50 bytes
Edit: -3 bytes by iamnotmaynard.
->a,b{(0..~-a.max/b).map{|i|a.count{|x|~-x/b==i}}}

Try it online!

This does not work when a.max is not a multiple of b (e.g. f[[1,1,1,2,7,10],3] => [4, 0, 1] but should give [4, 0, 2]). I had tried the same approach.

(or rather [4, 0, 1, 1])

Well, this is fixable by switching to a float max range value, but I'll also ask OP to clarify this in the task description.

50 bytes

Nice, even better, thanks.

This puzzle is essentially a Count-sort. We don't know the length of output without going through input first.
C (clang), 53 bytes
i,j;f(*A,l,b,*O){for(j=0;j<l;O[(A[j++]+b-1)/b-1]++);}

Try it online!
This solution takes following parameters:
A input array
l length of A
b bin_size
O storage for Output. Must be sufficient length
and returns output in O.
This solution has a handicap: it doesn't return the length of output array O, and so caller doesn't know how much to print.
Following version overcomes that handicap:
C (clang), 79 bytes
i,j,k;f(*A,l,b,*O,*m){for(k=j=0;j<l;O[i=(A[j++]+b-1)/b-1]++,k=k>i?k:i);*m=++k;}

Try it online!
It takes an additional parameter m and returns length of O in it. It cost me 26 bytes.


text:
Binary Fibonacci
Challenge
You need to generate a program or function that takes in a positive integer N, calculates the first N terms of the Fibonacci sequence in binary, concatenates it into a single binary number, converts that number back to decimal, and then outputs the decimal as an integer.
For example
1 -> [0] -> 0 to decimal outputs 0
3 -> [0, 1, 1] -> 011 to decimal outputs 3
4 -> [0, 1, 1, 10] -> 01110 to decimal outputs 14

You do not need to output the ->, just the number (e.g. if the user types 4, just output 14). The arrows are just to help explain what the program must do.
Test cases
1 -> 0
2 -> 1
3 -> 3
4 -> 14
5 -> 59
6 -> 477
7 -> 7640
8 -> 122253
9 -> 3912117
10 -> 250375522
11 -> 16024033463
12 -> 2051076283353
13 -> 525075528538512
14 -> 134419335305859305
15 -> 68822699676599964537
16 -> 70474444468838363686498
17 -> 72165831136090484414974939
18 -> 147795622166713312081868676669
19 -> 605370868394857726287334099638808
20 -> 4959198153890674493745840944241119317

The program must be able to output up to the limit of the language in use. No lookup tables or common workarounds allowed.
This is code-golf, so the answer with the shortest number of bytes wins!

Added test cases from 0 to 20 from https://tio.run/##DYxBCoQwDAC/Ejwl0Ih63vUj4qFWIjlsWrK9CP69dmDmOCW68lWawBea8Sqef6deWv@YsqVYcTvUot8oemSLKSkq0aMf3qZxNJ73ncJCTbKj9ckcYJkCFFerOEBnAOvy2iNoRNRe. Credit to @alephalpha for the program.

As it hasn't been said yet: Welcome to PPCG! Nice first challenge.

Where exactly does the language-specific limit apply?  Would a C function that returns a 32-bit integer be allowed?  Like int32_t binary_concat_Fib(int n), which would limit the resulting output value to 2^31-1.  i.e. you get to assume all the concatenated bits fit in an integer.  Or should the function work up to the point where the largest Fibonacci number doesn't fit in an integer on its own, so concatenating the bits takes extended precision?

@PeterCordes I'd say either is allowed, as long as it's at least int32 or that int.

And does the "converts to decimal" have to be explicit, calling an integer->string function or writing one yourself?  Concatenating the bits into a single integer gives you a representation of the final value.  If I understand correctly, Dennis's Python answer is returning an integer, leaving it up to the caller to turn that value into a decimal string or do whatever with it.  Integer values in computer languages that support bit-shift operators are naturally binary, not decimal, unless they're stored in strings.  In languages without shifts / bitwise operators, nothing implies any base.

The output should be an integer

Ok, so you were just describing it in terms of implementation in a language where you explode each bit to a list element, instead of normal bit shifts / manipulation where the result of packing bits together already is an integer.

@PeterCordes It goes like this. Calculate fibonacci up to N 4 -> [0, 1, 1, 2], change to binary [0, 1, 1, 10], concatenate it like a string 01110, convert it from base 2 to base 10 14

Well yeah if you had a string like "01110" then you'd have some conversion to do.  But if you had an integer like 0b01110 (note lack of quote marks; I'm using C++ syntax to represent a constant using ASCII digits for base 2, but I'm talking about those bits packed into an integer already), it would already also represent 14 in decimal, and 0xe in hex.  But it's still stored in memory / a register in binary until you print it to a string.  Dennis's Python answer doesn't have any list->decimal function because it never unpacked the bits in the first place (except to find log2(a).

Numbers in computers (like an int in C) aren't "in decimal" until you print / convert them to strings, unless you're using binary-coded-decimal or something weird like that.

Because no one have mentioned that, you can post your challenge in the sandbox before posting on main. (read the link for more details)

I would ask that you avoid using "dec" as an abbreviation for "decimal. "Dec" is the name for ten in base 12 which made me confused.

Python, 64 bytes
f=lambda n,a=0,b=1,r=0:n and f(n-1,b,a+b,r<<len(bin(a))-2|a)or r

Try it online!

Nice, I was just trying to achieve this style.

Jelly,  7  6 bytes
ḶÆḞBẎḄ

Try it online!
How?
ḶÆḞBẎḄ - Link: integer, n
Ḷ      - lowered range -> [0,1,2,3,4,5,...,n]
 ÆḞ    - Fibonacci (vectorises) -> [0,1,1,2,3,5...,F(n)]
   B   - to binary (vectorises) -> [[0],[1],[1],[1,0],[1,1],[1,0,1],...,B(F(n))]
    Ẏ  - tighten -> [0,1,1,1,0,1,1,1,0,1,...,B(F(n))[0],B(F(n))[1],...]
     Ḅ - from binary -> answer

Messing around with the new quicks, I found that the first n Fibonacci numbers can also be found using Ṛc’SƲƤ which could be useful for similar sequences.

Python 3.6, 61 bytes
f=lambda n,a=0,b=1:n and int(f'{a:b}{f(n-1,b,a+b)*2:b}',2)//2

Try it online!

Husk, 7 bytes
ḋṁḋ↑Θİf

Try it online!
Explanation
ḋṁḋ↑Θİf                              4
     İf    The Fibonacci numbers     [1,1,2,3,5,8..]
    Θ      Prepends 0                [0,1,1,2,3,5..]
   ↑     Take n elements from list   [0,1,1,2]
  ḋ        Convert to binary digits  [[0],[1],[1],[1,0]]
 ṁ       Map function then concat    [0,1,1,1,0]
ḋ        Convert from base 2         14

Welcome to PPCG! :)

brainfuck, 397 bytes
>,[<++++++[->--------<]>>[->++++++++++<]>[-<+>]<<[->+<],]>+[-<<+>>[-[->+<]<<[->+>+<<]<[->+>+<<]>[-<+>]>>[-<<+>>]>]]<<[->+>>>>>+<<<<<<]>[-<+>]>+>>+>>>+<[[->-[<<]>]>[[-]<<<<<<<[->>[-<+>>+<]>[-<+>]<<<]<[->+>>>>>+<<<<<<]>[-<+>]>[-<+>]>[->>[-<+<<+>>>]<[->+<]<]>+>[-]>>+>]<<<<<[[->++>+>++<<<]>[-<+>]<<]>>>]>[-]<<<[-]<<[-]<<->[>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>>>]<+[->++++++[-<++++++++>]<.<<<+]

Well, that was fun!
Takes ASCII input (e.g. 11), outputs result in ASCII.
Note: to try this online, make sure you set the cell size to 32 bits (on the right side of the webpage). If you do not enter an input, your browser might crash.
The interpreter cannot handle input of 11 and higher because it only supports up to 32 bits.
Try it on copy.sh
Explanation
>,[<++++++[->--------<]>>[->++++++++++<]>[-<+>]<<[->+<],]>+

Get decimal input and add one (to mitigate off-by-one)
[-<<+>>[-[->+<]<<[->+>+<<]<[->+>+<<]>[-<+>]>>[-<<+>>]>]]

Generate  fibonacci numbers on the tape.
<<[->+>>>>>+<<<<<<]>[-<+>]>+>>+>>>+<

Set up for the incoming binary concatenation loop

So the cells contain the value, starting from the first position,
1 | 0 | 1 | 1 | 2 | 3 | 5 | ... | f_n | 0 | 1 | 0 | 1 | 0 | f_n | 1 | 0 | 0 | 0...

Look at these cells:
f_n | 0 | 1 | 0 | 1 | 0 | f_n | 1

I'll label this:
num | sum | cat | 0 | pow | 0 | num | pow

pow is there to find the maximal power of 2 that is strictly greater than num. sum is the concatenation of numbers so far. cat is the power of 2 that I would need to multiply the num in order to concatenate num in front of the sum (so I would be able to simply add).

[[->-[<<]>]>

Loop: Check whether f_n is strictly less than pow.
Truthy:
[[-]<<<<<<<[->>[-<+>>+<]>[-<+>]<<<]<[->+>>>>>+<<<<<<]>[-<+>]>[-<+>]>[->>[-<+<<+>>>]<[->+<]<]>+>[-]>>+>]

Zero out junk. Then, add num * cat to sum. Next, load the next Fibonacci number (= f_(n-1); if it doesn't exist, exit loop) and set cat to cat * pow. Prepare for next loop (zero out more junk, shift scope by one).
Falsey:
<<<<<[[->++>+>++<<<]>[-<+>]<<]

Set pow to 2 * pow, restore num.
]

Repeat until there is no Fibonacci number left.

>[-]<<<[-]<<[-]<<->[>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>>>]<+[->++++++[-<++++++++>]<.<<<+]

Clean garbage. Take each digit of the resulting number and output each (in ascii).

Japt, 9 bytes
ÆMgX ¤Ã¬Í

Run it
Explanation:
ÆMgX ¤Ã¬Í
Æ     Ã     | Iterate X through the range [0...Input]
 MgX        |   Xth Fibonacci number
     ¤      |   Binary
       ¬    | Join into a string
        Í   | Convert into a base-2 number

Bah! Beat me to it!

@Shaggy I knew this one was going to be a race against you :P

Pyth, 22 bytes
JU2VQ=+Js>2J)is.BM<JQ2

Try it here
Explanation
JU2VQ=+Js>2J)is.BM<JQ2
JU2                       Set J = [0, 1].
   VQ       )             <Input> times...
     =+Js>2J              ... add the last 2 elements of J and put that in J.
                  <JQ     Take the first <input> elements...
               .BM        ... convert each to binary...
              s           ... concatenate them...
             i       2    ... and convert back to decimal.

JavaScript (Node.js), 70 65 58 57 55 bytes

thanks to Shaggy for reducing 2 bytes ('0b+C-0 to '0b'+C)

f=(n,a=C=0,b=1)=>--n?f(n,b,a+b,C+=b.toString(2)):'0b'+C

Try it online!

You can ditch the -0 at the end to save another 2 bytes.

Perl 6, 38 bytes
{:2([~] (0,1,*+*...*)[^$_]>>.base(2))}

Try it online!

Note that this starts to get noticeably slower with inputs above 200. It takes about 8 seconds to generate the output with an input of 1000. (20 seconds if you include printing it)

05AB1E, 6 bytes
LÅfbJC

Try it online!

1-indexed.

Pyth, 27 bytes
JU2V-Q2=aJ+eJ@J_2)is.BM<JQ2

Test suite

Python 3 translation:

Q=eval(input())
J=list(range(2))
for i in range(Q-2):
    J.append(J[-1]+J[-2])
print(int(''.join(map("{0:b}".format,J[:Q])),2))

37 bytes
J[Z1)W<lJQ=aJ+eJ@J_2)Ig1QZ.?ijkm.BdJ2

Test suite

Python 3 translation:

Q=eval(input())
J=[0,1]
while len(J)<Q:
    J.append(J[-1]+J[-2])
if 1>=Q:
    print(0)
else:
    print(int(''.join(map("{0:b}".format,J)),2))

x86, 37 22 21 bytes
Changelog

-13 by using bsr. Thanks Peter Cordes!
-2 by zeroing registers with mul.
-1 by using a while loop instead of loop and push/pop ecx (credit Peter Cordes).

Input in edi, output in edx.
.section .text
.globl main
main:
        mov     $5, %edi            # n = 5

start:
        dec     %edi                # Adjust loop count
        xor     %ebx, %ebx          # b = 0
        mul     %ebx                # a = result = 0
        inc     %ebx                # b = 1

fib:
        add     %ebx, %eax          # a += b
        xchg    %eax, %ebx          # swap a,b
        bsr     %eax, %ecx          # c = (bits of a) - 1
        inc     %ecx                # c += 1
        sal     %cl, %edx           # result >>= c
        add     %eax, %edx          # result += a

        dec     %edi                # n--; do while(n)
        jnz     fib

        ret

Objdump:
00000005 <start>:
   5:   4f                      dec    %edi
   6:   31 db                   xor    %ebx,%ebx
   8:   f7 e3                   mul    %ebx
   a:   43                      inc    %ebx

0000000b <fib>:
   b:   01 d8                   add    %ebx,%eax
   d:   93                      xchg   %eax,%ebx
   e:   0f bd c8                bsr    %eax,%ecx
  11:   41                      inc    %ecx
  12:   d3 e2                   shl    %cl,%edx
  14:   01 c2                   add    %eax,%edx
  16:   4f                      dec    %edi
  17:   75 f2                   jne    b <fib>
  19:   c3                      ret

Use lea to shift-and-add in fib2.  Also, extracting each bit one at a time is unnecessary.  Use bsr %eax, %ecx to find the number of bits in the binary representation, and use a shift by CL / or to merge, like Dennis's Python answer is doing.

@PeterCordes the source of this convoluted method is the result of a headache and a misinterpretation of the problem spec to use base 10 instead of base 2. I will fix.

Heh, see my comments on the question.  It drives me nuts when people think that integers are "in decimal" because that's how they wrote the constant.  This fuzzy thinking may be due to golfing and other languages that have functions to convert an integer to a list / array of elements, 1 per bit, and then using list manipulation instead of bitwise operations on integers.  Although I'm not sure how the "base 10" part of the problem statement got you, more like the way the examples were written with all bits separated leads you to unnecessary unpacking.  Headache would do it, though :/

You need cl for shift counts, so take your loop counter in a different reg (like %edi) and use dec %edi / jnz (3 bytes in 32-bit code, 4 bytes in 64-bit).  In 32-bit code, that saves 1 byte total from dropping the push/pop ecx.  Don't fall into the trap of using loop when it makes the problem harder, not easier.  (Your calling convention is already custom, clobbering %ebx, so don't call your function main)  You might be able to return in EAX while still taking advantage of 1-byte xchg, no need to be non-standard if you don't need to.

@PeterCordes aw I got so excited to use loop. :(

You can replace the extra inc %ecx of the shift count with an extra left-shift as you add, using lea (%eax, %edx, 2), %edx.  Neutral in bytes for 32-bit, saves one for x86-64.  But saves an instruction.

Every time I end up using loop in code golf, I feel dirty.  Well not quite, but disappointed that I couldn't find an equally small implementation that avoided that slow instruction; outside of code golf, loop is one of my pet peeves.  I wish it was fast on modern CPUs, because it would be very nice for extended-precision loops without partial-flag stalls, but it's not and should be considered only as an obscure size optimization instruction that makes your code slow.

re: result in EAX, no nvm, result stays in the same register the whole time, and you need EAX to be one of the Fibonacci registers for xchg.  So returning in EAX to make this MS __fastcall would cost an extra byte.

Anyway, nice job.  Other than push/pop/loop -> dec/jnz, I don't see any savings, just the LEA speedup that's neutral in code-size.  I'd always wondered if there was ever a real use case for the xor/mul trick to zero three registers (do you ever need that many zeroes?), but using that as part of creating a 1 makes it more sensible.

@PeterCordes Now that I think about it, working with ax is like working with ah and al at the same time. I wonder if there are any cool tricks involving that.

Yup, sure.  integer -> 2-digit decimal ASCII number with div %bl / add $0x3030, %ax (especially in 16-bit code) to give you a 2-byte ASCII string which stores to memory in printing order (10's place first, in AL).  You can even use aam to divide AL (rather than AX) by an immediate (default is 10), but the results go in opposite registers from div.  Or sometimes lodsw / xchg al,ah, maybe as part of sorting byte elements, again especially in x86-16.

J, 36 Bytes
3 :'#.;<@#:"0]2}.(,{:+_2&{)^:y _1 1'

Explanation:
3 :'#.;<@#:"0]2}.(,{:+_2&{)^:y _1 1' | Explicit function
                 (,{:+_2&{)^:y _1 1  | Make n fibonacci numbers, with _1 1 leading
              2}.                    | Drop the _1 1
       <@#:"0]                       | Convert each item to binary and box
      ;                              | Unbox and join
    #.                               | Convert back from binary

Haskell, 89 76 75 bytes
f=0:scanl(+)1f
foldr1(\x y->y+x*2*2^floor(logBase 2.read.show$y)).(`take`f)

Ungolfed version:
import Data.Bits

fib = 0:scanl (+) 1 fib

catInt :: Integer -> Integer -> Integer
catInt x y = x' + y where
    position = floor $ succ $ logBase 2 $ realToFrac y
    x' = shift x position

answer :: Integer -> Integer
answer n = foldr1 catInt fib' where
    fib' = take n fib

Welcome to PPCG and Haskell golfing in particular! A shorter way to generate an infinite list of Fibonacci numbers is f=0:scanl(+)1f (taken from here). Functions can be anonymous, so you can drop the leading g=, see our Guide to Ggolfing Rules in Haskell.

Thanks! That compensates for some of the longer functions used. I spent a while trying to find a way to implement bit-shifting in a more concise way, but came up short.

You can replace $realToFrac y with .read.show$y for one byte

APL (Dyalog), 26 22 bytes
4 bytes saved thanks to @H.PWiz
{2⊥∊2∘⊥⍣¯1¨1∧+∘÷\~⍵↑1}

Try it online!

Save 2 bytes on the fibonacci bit

Even shorter

Pari/GP, 59 bytes
n->fromdigits(concat([binary(fibonacci(i))|i<-[0..n-1]]),2)

Try it online!

APL+WIN, 55 bytes
Prompts for screen input of integer.
v←b←0 1⋄⍎∊(⎕-2)⍴⊂'v←v,c←+/¯2↑v⋄b←b,((1+⌊2⍟c)⍴2)⊤c⋄'⋄2⊥b

APL+WIN's maximum integer precision is 17 and integer limit is of the order of 10E300 therefore the maximum input number is 55 and the result is: 1.2492739026634838E300

Python 3, 94 bytes
f=lambda n,a=[0,1]:n>len(a)and f(n,a+[sum(a[-2:])])or int(''.join(bin(v)[2:]for v in a[:n]),2)

Try it online!

Jelly, 6 bytes
ḶÆḞBFḄ

Try it online!
Ḷowered range -> nth ÆḞibonacci number -> from dec to Binary -> Flatten -> from Ḅinary to dec

Didn't understand this language but I thought the output is not always correct. e.g. Input 10 and you will get an 16024033463, it is incorrect (correct answer is 250375522).

@AbrahamChin Input 10 returns 250375522

Equivalent, duplicate answer, just a heads up

MATL, 21 bytes
0li:"yy+]xx&h"@B]&hXB

Try it online!
Explanation
0l        % Push 0, then 1 (initial terms of the Fibonacci sequence)
i:"       % Do n times, where n is the input
  yy+     %   Duplicate top two numbers and push their sum
  ]       % End
xx        % Delete the last two results. The stack now contains the
          % first n Fibonacci numbers, starting at 0
&h        % Concatenate all numbers into a row vector
"         % For each
  @       %   Push current number
  B       %   Convert to binary. Gives a vector of 0 and 1
]         % End
&h        % Concatenate all vectors into a row vector
XB        % Convert from binary to decimal. Implicitly display

Jotlin, 59 bytes
g(l(0,1)){l(a.sum(),a[0])}.take(this).j(""){a[0].s(2)}.i(2)

Test Program
data class Test(val input: Int, val output: Long)

val tests = listOf(
    Test(1, 0),
    Test(2, 1),
    Test(3, 3),
    Test(4, 14),
    Test(5, 59),
    Test(6, 477),
    Test(7, 7640),
    Test(8, 122253),
    Test(9, 3912117),
    Test(10, 250375522)
)
fun Int.r() = g(l(0,1)){l(a.sum(),a[0])}.take(this).j(""){a[0].s(2)}.i(2)

fun main(args: Array<String>) {
    for (r in tests) {
        println("${r.input.r()} vs ${r.output}")
    }
}

It supports up to 10, changing .i(2) for .toLong(2) would support up to 14 if needed

J, 25 bytes
2(#.;)<@#:@(1#.<:!|.)\@i.

Try it online!
Explanation
2(#.;)<@#:@(1#.<:!|.)\@i.  Input: n
                       i.  Range [0, n)
                     \@    For each prefix
                  |.         Reverse
                 !           Binomial coefficient (vectorized)
               <:            Decrement
            1#.              Sum
        #:                   Convert to binary
      <                      Box
    ;                        Link. Join the contents in each box
2 #.                         Convert to decimal from base 2

Python 3, 86 bytes
def f(N):
 a,b,l=0,1,''
 for _ in range(N):l+=format(a,'b');a,b=b,a+b
 return int(l,2)

Try it online!

PHP, 124 Bytes
Try it online!
So I was looking for a way to output fibonacci numbers using the series, until I found this. It turns out you can calculate the fibonacci series via rounding, so I tried the challenge with a recursive function.
I found the approach of "rounding" really interesting, also a professor showed me this a while ago.
Code
function f($n,$i=0,$b=''){ if($n>$i){$b.=
decbin(round(pow((sqrt(5)+1)/2,$i)/sqrt(5)));f($n,$i+1,$b);}else{echo bindec($b);}}

Explanation
function f($n,$i=0,$b=''){           #the function starts with $i=0, our nth-fib number
if($n>$i){                           #it stops once $n (the input) = the nth-fib
    $b.=decbin(                      #decbin returns an integer as bin, concatenates
        round(pow((sqrt(5)+1)/2,$i)/sqrt(5))
                                       #the formula, basically roundign the expression
        );                           #it returns the (in this case) $i-th fib-number
    f($n,$i+1,$b);                   #function is called again for the next index
}else{                               #and the current string for fibonacci

    echo bindec($b);                 #"echo" the result, bindec returns the base 10
                                     #value of a base 2 number
}
}

Also check this stackoverflow post the best answer refers to the same article on Wikipedia.

Interesting way to do it!

Stax, 9 bytes
ü1∞╓♪εw≤+

Run and debug it at staxlang.xyz!
Unpacked (10 bytes) and explanation:
vr{|5|Bm|B
v             Decrement integer from input. Stax's Fibonacci sequence starts with 1 :(
 r            Integer range [0..n).
  {    m      Map a block over each value in an array.
   |5           Push nth Fibonacci number.
     |B         Convert to binary.
        |B    Implicit concatenate. Convert from binary. Implicit print.

Julia 0.6, 65 bytes
f(n)=n<2?n:f(n-1)+f(n-2)
n->parse(BigInt,prod(bin.(f.(0:n-1))),2)

Try it online!

Add++, 113 bytes
D,f,@@@@*,V$2D+G1+dAppp=0$Qp{f}p
D,k,@,¿1=,1,bM¿
D,g,@,¿1_,1_001${f},1¿{k}
D,w,@,BBbR
D,l,@,ßR€gp€w@0b]@¦+VcG2$Bb

Try it online!

Factor + project-euler.025, 37 bytes
[ iota [ fib >bin ] map-concat bin> ]

Try it online!

Vyxal, 44 bits1, 5.5 bytes
ʁ∆FbfB

Try it Online!
Explained
ʁ∆FbfB
ʁ      # range [0, input)
 ∆F    # 0-indexed fibonacci number of each
   bf  # convert each to binary and flatten the list
     B # convert that from binary

Ruby, 61 bytes
->n,a=0,b=1,s=""{s+="%b"%a;a,b=b,a+b;(n-=1)>0?redo:s.to_i(2)}

Try it online!

R, 244 180 179 bytes
i=ifelse;g=function(n)i(n<3,1,g(n-1)+g(n-2))
a=scan(,"");i(a==1,0,sum(2^(which(rev(unlist(sapply(g(2:a-1),function(x)(y=rev(as.numeric(intToBits(x))))[which(!!y)[1]:32]))>0))-1)))

Try it online!
Saved some bytes by concatenating numeric vectors, not strings. Bloody special case for 0!

Functions are acceptable. Also it is much more efficient to shift the result left by the number of bits then to bother with numeric vectors. See my or Dennis's python answer. This has the added benefit of handling the 0 case.

https://codegolf.stackexchange.com/questions/4024/tips-for-golfing-in-r R golfing is too much for me :/

@qwr The answer is not a function; I am creating a helper function because it must be sapply’d to a vector due to the fact that it is recursive. It cannot be all wrapped into one line. As you see, the programme prompts for user’s input and then returns the answer. One byte can be saved by creating a shortcut for ifelse. And... we can remove ,"" from scan, yes.

Python 2, 88 bytes
def f(n):
 a,b,r=0,1,"0"
 for _ in range(n-1):a,b=b,a+b;r+=bin(a)[2:]
 print int(r,2)

Python 3, 74 bytes
w='';a,b=0,1
exec('w+=bin(a)[2:];a,b=b,a+b;'*int(input()))
print(int(w,2))

Try it online!
Ungolfed:
w = ''
a, b = 0, 1
for _ in ' '*int(input()):  # for 0 to input:
    w += bin(a)[2:]         # append next fib. number as binary
    a, b = b, a + b         #     without leading 0b
print(int(w,2))             # convert whole binary number to decimal int

Julia 0.6, 60 bytes
f(n,a=0,b=1,r=big(0))=n<1?r:f(n-1,b,a+b,r<<length(bin(a))|a)

Inspired by Dennis's bit fiddling python answer.
Try it online!

JavaScript (Node.js), 75 bytes
Non-recursive solution. (Doesn't beat the recursive one)
n=>"0b"+[...Array(n)].map(c=>(c=a,a=b,b+=c,c).toString(2),a=0,b=1).join``-0

Try it online!

Thunno 2, 6 bytes
LÆFḃJḂ

Port of Jonathan Allan's Jelly answer.
Explanation
LÆFḃJḂ  # Implicit input                              Input: 4
L       # Lowered range: push [0..input)              Stack: [0, 1, 2, 3]
 ÆF     # nth Fibonacci number (vectorises)           Stack: [0, 1, 1, 2]
   ḃ    # Convert to a binary string (vectorises)     Stack: ["0", "1", "1", "10"]
    J   # Join into a single string                   Stack: "01110"
     Ḃ  # Convert from binary                         Stack: 14
        # Implicit output                            Output: 14

Screenshot

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
1, 2, 3, 14... or is it 15?
A well known song by the Irish rock band U2 starts with the singer Bono saying "1, 2, 3, 14" in Spanish ("uno, dos, tres, catorce").
There are various theories as to the significance of those numbers. Apparently the official explanation is "we drank too much that night". But there's a more interesting hypothesis: Bono is referring to some integer sequence from OEIS, such as
A107083:

Integers k such that 10^k + 31 is prime.
1, 2, 3, 14, 18, 44, 54, ...

In an interview, when asked the inevitable question "why 14", Bono admitted he was a bit tired of that number. The journalist suggested "15" instead, and in that night's concert the lyrics were indeed changed into "1, 2, 3, 15". (The story can be read here, in Spanish). Quite likely the journalist took inspiration from
A221860:

Indices k such that prime(k) - k is a power of 2, where prime(k) is the k-th prime.
1, 2, 3, 15, 39, 2119, 4189897, ...

The challenge
Write two programs in the same language. The first should take an input n and output the n-th term of A107083, or the first n terms. Similarly, the second should output the n-th term of A221860, or the first n terms.
The score is the sum of lengths of the two programs, in bytes, plus the square of the Levenshtein distance between the byte representations of the two programs.
If a character encoding is used such that each character corresponds to one byte, this script can be used to measure Levenshtein distance.
For example, if the two programs are abcdefgh and bcdEEfg, the score is 8 + 7 + 4^2 = 31.
Lowest score wins.
Aditional rules

The output can be 1-based or 0-based, independently for each sequence (so it is allowed if one of the programs is 1-based and the other is 0-based).
Each program can, consistently but independently of the other, either output the n-th term or the first n terms.
Programs or functions are allowed, independently for each sequence.
Input and output means and format are flexible as usual. Standard loopholes are forbidden.

Jelly, 16 + 16 + 1² = 33
A107083
⁵*+31ÆḍÆNB>/
1Ç#

Try it online!
A221860
⁵*+31ÆạÆNB>/
1Ç#

Try it online!
How it works
1Ç#           Main link. Argument: n

1             Set the return value to 1.
 Ç#           Call the helper link with arguments k, k + 1, k + 2, ... until n of
              them return a truthy value. Return the array of n matches.

⁵*+31ÆḍÆNB>/  Helper link. Argument: k

⁵*            Yield 10**k.
  +31         Yield 10**k + 31.
     Æḍ       Count the proper divisors of 10**k + 31.
              This yields c = 1 if 10**k + 31 is prime, an integer c > 1 otherwise.
       ÆN     Yield the c-th prime.
              This yields q = 2 if 10**k + 31 is prime, a prime q > 2 otherwise.
         B    Binary; yield the array of q's digits in base 2.
          >/  Reduce by "greater than".
              This yields 1 if and only if the binary digits match the regex /10*/,
              i.e., iff q is a power of 2, i.e., iff 10**k + 31 is prime.

⁵*+31ÆạÆNB>/  Helper link. Argument: k

     Æ        Unrecognized token.
              The token, as well as all links to its left, are ignored.
       ÆN     Yield p, the k-th prime.
      ạ       Take the absolute difference of k and p, i.e., p - k.
         B    Binary; yield the array of (p - k)'s digits in base 2.
          >/  Reduce by "greater than".
              This yields 1 if and only if the binary digits match the regex /10*/,
              i.e., iff p - k is a power of 2.

Pyth, 9 + 11 + 9² = 101 bytes
1, 2, 3, 14
.fP_+31^T

Try it online!
1, 2, 3, 15
.fsIl-e.fP_

Try it online!

Jelly, 12 + 12 + 8² = 88 bytes
1, 2, 3, 14
ÆN_µæḟ2=
1Ç#

Try it online!
1, 2, 3, 15
10*+31ÆP
1Ç#

Try it online!

It should output the nth term, not the first n terms 2) Hey, one of our snippets are almost the same! 3) Uhh... that 10 feels very long.

Instead of outputting the n-th term, each program can independently output the first n terms.

Hm, so that would make my answer kind of have a smaller score.

@EriktheOutgolfer Sorry about the confusion, I've incorporated that into the main text for greater clarity (previously it was only under "additional rules")

Jelly, 11B + 10B + 7B² = 70
1, 2, 3, 14
⁵*+31ÆP
1Ç#

Try it online!
1, 2, 3, 15
ạÆNBSỊ
1Ç#

Try it online!

MATL, 17+17+7² = 83
1, 2, 3, 14, ... (17 bytes)
0G:"`Q11qy^31+Zp~

Try it online!
1, 2, 3, 15, ... (17 bytes)
0G:"`QtYqy-Bzq~p~

Try it online!
Both employ the similar scheme of 0G:"`Q to have a counter running up and returning when a condition has been met n times. The actual program then is fairly straightforward. The 15 variant has some filler (~p~) to minimise the Levenshtein distance, while the 14 program employs an 11qy rather than t10w to match the other program better.
Shared part:
0      % Push counter (initially zero)
 G:"   % Loop `n` times
    `  % Do .... while true
     Q % Increment counter

Top program:
11q         % Push 10
   y        % Duplicate counter
    ^       % Power
     31+    % Add 31
        Zp  % isprime
          ~ % If not, implicitly continue to next iteration.
            % Else, implicit display of counter.

Bottom program:
tYq         % Nth prime based on counter
   y-       % Duplicate counter, subtract from nth prime.
     Bzq    % Number of ones in binary presentation, minus one (only zero for powers of two).
        ~p~ % Filler, effectively a NOP.
            % If not zero, implicitly continue to next iteration
            % Else, implicitl display of counter.

05AB1E (legacy), 10 + 11 + 62 = 84 69 57 bytes
1, 2, 3, 14, ... (A107083)
Îµ>Ð°32<+p

Try it online.
1, 2, 3, 15, ... (A221860)
Îµ>Ð<ØαD<&_

Try it online.
Both output the 1-based \$n\$th value.
Uses the legacy version of 05AB1E, since it does ½ (increase counter_variable by 1 if the top of the stack is truthy) implicitly after each iteration of µ-loops (while counter_variable is not equal to \$a\$ yet, do ...).
Explanation:
Î            # Push 0 and the input
 µ           # While the counter_variable is not equal to the input yet:
  >          #  Increase the top by 1
   Ð         #  Triplicate it (which is our `k`)
    °32<+    #  Take 10 to the power `k`, and add 31
         p   #  Check if this is a prime
             #  (implicit: if it is a prime, increase the counter_variable by 1)
             # (implicitly output the top of the stack after the while-loop)

Î            # Push 0 and the input
 µ           # While the counter_variable is not equal to the input yet:
  >          #  Increase the top by 1
   Ð         #  Triplicate it (which is out `k`)
    <Ø       #  Get the 0-indexed k'th prime
      α      #  Get the absolute difference of this prime with the copied `k`
       D<&   #  Calculate `k` Bitwise-AND `k-1`
          _  #  And check if this is 0 (which means it's a power of 2)
             #  (implicit: if it is 0, increase the counter_variable by 1)
             # (implicitly output the top of the stack after the while-loop)

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Simulating Crashing Cars
Introduction
I have some ASCII cars that have velocity and direction. Their velocity is represented by their number. If a car is <> then it has stopped. For example:
<>
1>
2>
3>

After one second, I get
<>
 1>
  2>
   3>

After two, I get
<>
  1>
    2>
      3>

If two cars are too close, they crash.
1> <1
1> <2

After a second, this becomes
 ###
 ##

If two cars intersect, they become hashtags were they would be.
If one car is fast enough to 'hop' over the other, it does not result in a crash.
3><1   2><1   4><>

becomes
 <13>   ###     <>4>

If a car goes left off-screen, it disappears (unless there's a crash). There is no way for a car to go right off-screen.
 <11>
<1  1>
1    1>
      1>

Challenge
Based on the given car physics, you must create a program that can time-step one second into the future. The input will be cars with spaces and a maximum velocity of 5 (matching regex (<[1-5]|[1-5]>|<>| )+). The simulation will happen on one line, however that line has no fixed size.
Test cases
<> 1> 2> 3> 4> 5>
<>  1>  2>  3>  4>  5>

1><1   1> <1   1>  <1
 ##     ###     1><1

2><2   2> <2   2>  <2   2>   <2   2>    <2
<22>    ###      ##       ###       2><2

<22>  <1 3>   <2
    ###     ##

<><>     1><>     2><>     3><>     4><>     5><>
<><>      ###       ##       ###      <>4>     <> 5>

<><1 <2 <3 <4 <5
###<2<3<4<5

Scoring
This is code-golf, so code with the smallest number of bytes wins!

<22>  <1 3>   <2
2   ###     ##
2 should not be there - there are other problemts with the outputs

i would suggest adding "<><1 <2 <3 <4 <5" "###<2<3<4<5" to the testcases - case were a crush happens but and other cars "touching" but not part of it

@DanielIndie That's an interesting one. I went ahead and edited the challenge.

It costs me some time to know <> mean one of velocity 0

Sorry! I added that in after writing everything so I forgot to explain it.

Is it possible that more than two cars crash together?

@l4m2. Yes. If they intersect, then they all become hashes.

JavaScript (ES6), 140 bytes
s=>[...s.replace(/\S./g,([a,b],i)=>r[r[i+=+b?-b:~~a]=r[i]?C:a,++i]=r[i]?C:b,r=[],C='#')&&r].map((c,i)=>c?r[i-1]==C|r[i+1]==C?C:c:' ').join``

Try it online!
Commented
s =>                      // given the input string s
  [ ...s.replace(         // search in s ...
    /\S./g,               //   ... all substrings consisting of 2 non-whitespace characters
    ([a, b], i) =>        //   let a be the 1st character, b the 2nd one and i the position
      r[                  //   update r[]:
        r[i +=            //     apply the car velocity to i:
          +b ? -b         //       if b is a digit, then move b cells backwards
                  : ~~a   //       else: use a to move forwards (or don't move at all)
        ] = r[i] ? C : a, //     if r[i] is set, overwrite it with '#'; otherwise, insert a
        ++i               //     increment i for the 2nd character
      ] = r[i] ? C : b,   //     if r[i] is set, overwrite it with '#'; otherwise, insert b
      r = [],             //   initialize r[] to an empty array
      C = '#'             //   define C as the 'crash' character
  ) && r ]                // end of replace(); return a fully iterable copy of r[]
  .map((c, i) =>          // for each entry c at position i in this array:
    c ?                   //   if c is defined:
      r[i - 1] == C |     //     if either the previous
      r[i + 1] == C ?     //     or the next cell is '#' (in the original array):
        C                 //       replace the current cell with '#'
      :                   //     else:
        c                 //       let c unchanged
    :                     //   else:
      ' '                 //     insert a space
  ).join``                // end of map(); join the result

JavaScript (Node.js), 259 bytes
254 to 259 because i added test case which wasnt in the testcases that complicated my result regex finder

s=>{
c=[]
n=[S=""]
s.replace(/<?\d>?|<>/g,([d,D],i)=>d>0?g(i+ +d,d)+g(i-~d,D):g(i-~~D,d)+g(i-~~D+1,D))
for(i of n)S+=i||" "
return S.replace(/1?[2-9]*1?/g,(d,i)=>d>"1".repeat(l=d.length)?"#".repeat(l):c.slice(i,i+l).join``)}
g=(x,p)=>x<0||(n[x]=-~n[x],c[x]=p)

Try it online!

Retina, 178 bytes
^\d([^>])
 $1
T`5-1`d`<.
 *(<(\d)|((\d)>|<>))
$2* $#3*5* $4* $.`* $&¶
T`d`5-1`<.
m`^.{0,5}

G`.
N^$`
$.&
{+m`\A( *)  (.*)¶\1(..?)$
$1$3$2
m`^\A( *)( *)..(.*)¶\1(..?)$
$1##$.2*#$3

Try it online! Link includes test cases. Explanation:
^\d([^>])
 $1

Handle the case of a car moving off the left.
T`5-1`d`<.

Temporarily complement the digits of cars moving to the left.
 *(<(\d)|((\d)>|<>))
$2* $#3*5* $4* $.`* $&¶

Put each car on its own line ($.`* $&¶) and add some indent depending on the speed of the car; left-moving cars get the complemented speed, while non-moving cars get 5 more than the speed.
T`d`5-1`<.

Uncomplement the left-moving car digits.
m`^.{0,5}

Move all of the cars 5 to the left. This fixes the indent for all cars.
G`.

Delete all cars that have moved off the left.
N^$`
$.&

Sort the remaining cars in reverse horizontal order.
{

Repeat the remaining stages until all the cars have been processed.
+m`\A( *)  (.*)¶\1(..?)$
$1$3$2

As long as the next car does not crash, add it to the result.
m`^\A( *)( *)..(.*)¶\1(..?)$
$1##$.2*#$3

Add a crashing car to the result.


text:
The Double's Base
Background
IEEE 754 Double-precision floating-point format is a way to represent real numbers with 64 bits. It looks like the following:

A real number n is converted to a double in the following manner:

The sign bit s is 0 if the number is positive, 1 otherwise.
The absolute value of n is represented in the form 2**y * 1.xxx, i.e. a power-of-2 times a base.
The exponent e is y (the power of 2) plus 1023.
The fraction f is the xxx part (fractional part of the base), taking the most significant 52 bits.

Conversely, a bit pattern (defined by sign s, exponent e and fraction f, each an integer) represents the number:
(s ? -1 : 1) * 2 ** (e - 1023) * (1 + f / (2 ** 52))

Challenge
Given a real number n, output its 52-bit fraction part of the double representation of n as an integer.
Test Cases
0.0        =>                0
16.0       =>                0
0.0625     =>                0
1.2        =>  900719925474099 (hex 3333333333333)
3.1        => 2476979795053773 (hex 8cccccccccccd)
3.5        => 3377699720527872 (hex c000000000000)
10.0       => 1125899906842624 (hex 4000000000000)
1234567.0  =>  798825262350336 (hex 2d68700000000)
1e-256     => 2258570371166019 (hex 8062864ac6f43)
1e+256     => 1495187628212028 (hex 54fdd7f73bf3c)

-0.0       =>                0
-16.0      =>                0
-0.0625    =>                0
-1.2       =>  900719925474099 (hex 3333333333333)
-3.1       => 2476979795053773 (hex 8cccccccccccd)
-3.5       => 3377699720527872 (hex c000000000000)
-10.0      => 1125899906842624 (hex 4000000000000)
-1234567.0 =>  798825262350336 (hex 2d68700000000)
-1e-256    => 2258570371166019 (hex 8062864ac6f43)
-1e+256    => 1495187628212028 (hex 54fdd7f73bf3c)

You can check other numbers using this C reference which uses bit fields and a union.
Note that the expected answer is the same for +n and -n for any number n.
Input and Output
Standard rules apply.
Accepted input format:

A floating-point number, at least having double precision internally
A string representation of the number in decimal (you don't need to support scientific notation, since you can use 1000...00 or 0.0000...01 as input)

For output, a rounding error at the least significant bit is tolerable.
Winning Condition
This is code-golf, so the lowest bytes in each language wins.

Sandbox post (deleted)

The test cases include only non-negative numbers. Can the input be negative?

@Dennis Yes. I'll add some more test cases.

Your description of the IEEE floating point format doesn't mention denormal numbers which are interpreted in a slightly different way (no implicit leading 1). Do denormals have to be handled correctly?

@nwellnhof You don't need to consider denormals, NaN and Infinity.

Related: View float numbers in graphical binary

@DLosc Oh yes, it should be plus. Also added test cases for 16 and 0.0625.

C (gcc), 42 30 bytes
long f(long*p){p=*p&~0UL>>12;}

Takes a pointer to a double as argument and returns a long.
Requires 64-bit longs and gcc (undefined behavior).
Thanks to @nwellnhof for -2 bytes!
Try it online!

&~0UL>>12 is two bytes shorter. The macro only works with lvalues, though.

Use macro -Df(x)=*(long *)&x&~0UL>>12, save 3 bytes. TIO

Haskell, 27 31 bytes
(`mod`2^52).abs.fst.decodeFloat

decodeFloat returns the significand and the exponent, but for some reason the former is 53 bit in Haskell, so we have to cut one bit off.
Try it online!

MATL, 10 bytes
IZ%52W\0YA

Try it online!
Explanation
        % Implicit input
IZ%     % Cast to uint64 without changing underlying byte representation
52W     % Push 2^52
\       % Modulus
0YA     % Convert to decimal. Gives a string. This is needed to avoid
        % the number being displayed in scientific notation
        % Implicit display

Python 3, 54 50 bytes
f=lambda x:int(x.hex().split('.')[1].split('p')[0],16)

Try it online!
With Kirill's suggestion:
f=lambda x:int(x.hex()[4+(x<0):].split('p')[0],16)

Try it online!

I might be wrong, but I think Python's hex() gives normalized notation that always starts with 0x1.. If so, you could just use this for 44 bytes.

Well, I forgot about negative numbers, so it looks like 50 bytes after all.

@kirill-l It doesn't always start with "1." (see for example (2**-1028)) but the OP doesn't say anything about subnormals, so I guess your second suggestion is acceptable. Please feel free to edit.

Actually in a recent comment the OP explicitly says we can safely ignore subnormals.

x86_64 machine language for Linux, 14 bytes
0:       66 48 0f 7e c0          movq   %xmm0,%rax
5:       48 c1 e0 0c             shl    $0xc,%rax
9:       48 c1 e8 0c             shr    $0xc,%rax
d:       c3                      retq

Try it online!
EDIT: Thanks to @Bubbler

try and use your own CC instead of the standard ABI. By requiring the double be in rax, you can easily drop the entire move from xmm0.
Only change needed for this is to make the test framework in ASM rather than C (Unless GCC is extra smart).

Fixed TIO

JavaScript (ES7), 52 50 bytes

f=n=>n?n<0?f(-n):n<1?f(n*2):n<2?--n*2**52:f(n/2):0
<input oninput=o.textContent=f(this.value)><pre id=o>0

Not using Math.floor(Math.log2(n)) because it's not guaranteed to be accurate. Edit: Saved 2 bytes thanks to @DanielIndie.

why not --n*2**52

@DanielIndie Because I forgot that that golf works with floats...

Perl 5 -pl, 28 bytes
$_=-1>>12&unpack Q,pack d,$_

Try it online!
The 1e-256 and 1e256 test cases are off but that's because Perl 5 converts huge or tiny floating point strings inexactly.

JavaScript (ES7), 98 76 bytes
Saved 22 (!) bytes thanks to @Neil
More verbose than Neil's answer, but I wanted to give it a try with typed arrays.
(n,[l,h]=new Uint32Array(new Float64Array([n]).buffer))=>(h&-1>>>12)*2**32+l

Try it online!

ES7 + UInt32Array saves 22 bytes: (n,[l,h]=new Uint32Array(new Float64Array([n]).buffer))=>(h&-1>>>12)*2**32+l

Is there any interpreter which had implemented BigInt64Array already?

C (gcc) macro, 49 bytes
-DF(x)=x?ldexp(frexp(fabs(x),(int[1]){})-.5,53):0

Try it online!
Returns a double but assuming IEEE precision, it won't have a fractional part. Also handles negative numbers now.

T-SQL, 80 bytes
SELECT CAST(CAST(n AS BINARY(8))AS BIGINT)&CAST(4503599627370495AS BIGINT)FROM t

The input is taken from the column n of a table named t:
CREATE TABLE t (n FLOAT)
INSERT INTO t VALUES (0.0),(1.2),(3.1),(3.5),(10.0),(1234567.0),(1e-256),(1e+256)

SQLFiddle

Hoon, 25 bytes
|*(* (mod +< (pow 2 52)))

Create a generic function that returns the input mod 2^52.
Calling it:
> %.  .~1e256
  |*(* (mod +< (pow 2 52)))
1.495.187.628.212.028

I never thought I would see hoon here.  I tried to understand urbit a couple of years back, but couldn't really make heads or tails of it.

Stax, 19 14 bytes
üâïc-Hò~÷]ó┬ó♪

Run and debug it
Unpacked, ungolfed, and commented, the code looks like this.
|a      absolute value
{HcDw   double until there's no fractional part
@       convert to integer type
:B      convert to binary digits
D52(    drop the first digit, then pad to 52
:b      convert back number

Run this one

APL (Dyalog), 38 bytes
{0=⍵:0⋄(2*52)×¯1+×∘2⍣(1≤⊣)÷∘2⍣(1>⊣)|⍵}

Try it online!

Rust, 21 bytes
|p|p.to_bits()&!0>>12

Pretty much copied C solution. Takes an f64 argument.
Try it online!

Forth (gforth), 42 bytes
Assumes floats are double by default and cells are 8 bytes in length (as is the case on my computer and TIO)
: f f, here float - @ $fffffffffffff and ;

Try it online!
Explanation
f,             \ take the top of the floating point stack and store it in memory
here float -   \ subtract the size of a float from the top of the dictionary
@              \ grab the value at the address calculated above and stick it on the stack
$fffffffffffff \ place the bitmask (equivalent to 52 1's in binary) on the stack
and            \ apply the bitmask to discard the first 12 bits

Forth (gforth) 4-byte cell answer, 40 bytes
Some older forth installations default to 4-byte cells, instead
: f f, here float - 2@ swap $FFFFF and ;

Explanation
f,             \ take the top of the floating point stack and store it in memory
here float -   \ subtract the size of a float from the top of the dictionary
2@             \ grab the value at the address above and put it in the top two stack cells
swap           \ swap the top two cells put the number in double-cell order
$fffff         \ place the bitmask (equivalent to 20 1's in binary) on the stack
and            \ apply the bitmask to discard the first 12 bits of the higher-order cell

Go, 68 bytes
import."math"
func d(n float64)uint64{return Float64bits(n)<<12>>12}

Can't do the &-1 trick because Go disallows overflows.
Attempt This Online!

Ruby, 39 bytes
->n{[n].pack(?D).unpack(?Q)[0]&~-2**52}

Try it online!

Java 8 or later, 38 bytes
x->Double.doubleToLongBits(x)&-1L>>>12

Try it online!

Aarch64 machine language for Linux, 12 bytes
0:   9e660000        fmov x0, d0
4:   9240cc00        and  x0, x0, #0xfffffffffffff
8:   d65f03c0        ret

To try this out, compile and run the following C program on any Aarch64 Linux machine or (Aarch64) Android device running Termux
#include<stdio.h>
const char f[]="\0\0f\x9e\0\xcc@\x92\xc0\3_\xd6";
int main(){
  double io[] = { 0.0,
                  1.2,
                  3.1,
                  3.5,
                 10.0,
            1234567.0,
               1e-256,
               1e+256,
                 -0.0,
                 -1.2,
                 -3.1,
                 -3.5,
                -10.0,
           -1234567.0,
              -1e-256,
              -1e+256 };

  for (int i = 0; i < sizeof io / sizeof*io; i++) {
    double input = io[i];
    long output = ((long(*)(double))f)(io[i]);

    printf("%-8.7g => %16lu (hex %1$013lx)\n", input, output);
  }
}

Julia 0.4, 30 bytes
x->reinterpret(UInt,x)<<12>>12

Try it online!

05AB1E, 18 bytes
Ä[ÐïQ#·}b0₃×«À52£C

Port of @recursive's Stax answer.
Try it online or verify all test cases.
Alternatively:
_+Ä[DbD53∍©›#·}®¦C

Try it online or verify all test cases.
Alternatively (by porting @LucaCiti's Python answer in the legacy version of 05AB1E):
Ä".hex()"«.E„.p¡Hà

Try it online or verify all test cases.
Explanation:
Ä             # Get the absolute value of the (implicit) input-float
 [            # Start an infinite loop:
  Ð           #  Triplicate the current value
   ï          #  Cast the top to an integer
    Q         #  Check if the top two values are the same†
     #        #  If they are: stop the infinite loop
  ·           #  Double the current float
 }b           # After the loop: convert the integer to a binary string
   0₃×«       # Append 95 trailing 0s
              # (95 is the smallest single-byte constant >= 52)
       À      # Rotate it once towards the left, so the leading 1 becomes trailing
        52£   # Only keep the first 52 bits
           C  # Convert it from a binary string to a base-10 integer
              # (which is output implicitly as result)

_             # Check if the (implicit) input-float is 0
 +            # Add it to the (implicit) input-float so it becomes 1
  Ä           # Convert it to its absolute value
[             # Start an infinite loop:
 D            #  Duplicate the current value
  b           #  Convert its integer part to a binary string
   D          #  Duplicate this string
    53∍       #  Extend/shorten it to size 53
       ©      #  Store this result in variable `®`
        ›     #  Check if it's larger than the binary string
         #    #  If it is: stop the infinite loop
 ·            #  Double the current float
}®            # After the loop: push binary string `®` which we've saved
  ¦           # Remove its leading 1
   C          # Convert it from a binary string to a base-10 integer
              # (which is output implicitly as result)

Ä             # Get the absolute value of the (implicit) input-float††
 ".hex()"«    # Append string ".hex()"
          .E  # Evaluate and execute it as Python code
„.p¡          # Split it on both the "." and "p"
    H         # Convert each inner part from a hexadecimal string to an integer
     à        # Push the maximum of this list
              # (which is output implicitly as result)

† If 05AB1E didn't had this bug and the input format is also guaranteed to not contain any additional trailing 0 besides #.0 (e.g. 12.0 is a valid input, but 12 or 12.10 aren't), the DïQ could have been ¤_ - which checks if the float contains a trailing zero.
†† Unlike the Python answer, .hex() doesn't work on negative values in the legacy version of 05AB1E, unless I add parenthesis around it (e.g. -1.0.hex() doesn't work, but 1.0.hex() and (-1.0).hex() both do: try it online), which is why the Ä was necessary in the third program.


text:
Write a Shape Simplifier
Introduction
I have a lot of ASCII rocks. They are built with dashes, pipes, Vs, carets, angle brackets, slashes and spaces. Example:
/--\
|  |
|  |
\--/

I want to erode them, like this:
 /\
/  \
\  /
 \/

All of the corners have become rounder. A more complicated example:
/----\
|     \------\
|            |
|            |
\------------/

 /--\
/    \------\
|            \
\            /
 \----------/

After another erosion, it would become
  /\
 /  \------\
<           \
 \          /
  \--------/

And another:
  /\------\
 <         \
  \        /
   \------/

Challenge
Your challenge is to write a program that can erode an input once. You can assume there is only one rock and you can assume it is one closed loop. The input will only contain the chars /\ -| <> ^V \n and will have trailing spaces to create a rectangle. The program can either get input from STDIN and output to STDOUT or can be a function. At the end of each row is a newline character. The erosion must follow the rules outlined below (Note: in the examples the rock isn't completed, this is for ease of explanation). The output must be in the same format as the input, with the same size as the input. However, trailing spaces may be omitted.
The slashes will spread to pipelines and dashes and move across.
/---
|
|

 /--
/
|

  /-
 /
/

If two slashes merge together, the appropriate character out of <>^V is used.
/-----\
|     |
|     |
|     |
\-----/

 /---\
/     \
|     |
\     /
 \---/

  /-\
 /   \
<     >
 \   /
  \-/

   ^
  / \
 <   >
  \ /
   V

If a part of the rock can merge, it will. Note: if one part can merge but the other can't (i.e, /\ in the second line of the example), then the one that can merge will (see example).
          /\
 /\-^-/\-/  \--
 |
 <
 |
 /
 \
 |
 /
/
\
 \
 |
 |

  /-------/\--
 /
 |
 |
 |
 |
 |
 |
 /
 \
 |
 |
 |

Eventually, all rocks will become nothing.
<>  ^  /\
    V  \/

Test cases
Test 1:
/----\
|     \------\
|            |
|            |
\------------/

 /--\
/    \------\
|            \
\            /
 \----------/

  /\
 /  \------\
<           \
 \          /
  \--------/

  /\------\
 <         \
  \        /
   \------/

   /-----\
  <       \
   \      /
    \----/

    /---\
   <     \
    \    /
     \--/

     /-\
    <   \
     \  /
      \/

      ^
     < \
      \/

Test 2:
/----\
|    |
|    |
|    |
|    |
\----/

 /--\
/    \
|    |
|    |
\    /
 \--/

  /\
 /  \
/    \
\    /
 \  /
  \/

  /\
 /  \
 \  /
  \/

  /\
  \/

Test 3:
          ^    /\
 /\--/\--/ \--/  \-\
 \                 |
 |                 |
 /                 |
 \                 |
 |                 |
 |                 |
 /                 |
<                  |
 \                 |
 |                 |
 |                 |
 /                 |
/                  |
\                  |
 \-----------------/

  /-------^----/\-\
 /                 \
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 <                 |
 |                 |
 |                 |
 |                 |
 |                 |
 /                 |
 \                 /
  \---------------/

   /-------------\
  /               \
 /                 \
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 \                 /
  \               /
   \-------------/

    /-----------\
   /             \
  /               \
 /                 \
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 \                 /
  \               /
   \             /
    \-----------/

     /---------\
    /           \
   /             \
  /               \
 /                 \
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 |                 |
 \                 /
  \               /
   \             /
    \           /
     \---------/

      /-------\
     /         \
    /           \
   /             \
  /               \
 /                 \
 |                 |
 |                 |
 |                 |
 |                 |
 \                 /
  \               /
   \             /
    \           /
     \         /
      \-------/

       /-----\
      /       \
     /         \
    /           \
   /             \
  /               \
 /                 \
 |                 |
 |                 |
 \                 /
  \               /
   \             /
    \           /
     \         /
      \       /
       \-----/

        /---\
       /     \
      /       \
     /         \
    /           \
   /             \
  /               \
 /                 \
 \                 /
  \               /
   \             /
    \           /
     \         /
      \       /
       \     /
        \---/

         /-\
        /   \
       /     \
      /       \
     /         \
    /           \
   /             \
  /               \
  \               /
   \             /
    \           /
     \         /
      \       /
       \     /
        \   /
         \-/

          ^
         / \
        /   \
       /     \
      /       \
     /         \
    /           \
   /             \
   \             /
    \           /
     \         /
      \       /
       \     /
        \   /
         \ /
          V

          ^
         / \
        /   \
       /     \
      /       \
     /         \
    /           \
    \           /
     \         /
      \       /
       \     /
        \   /
         \ /
          V

          ^
         / \
        /   \
       /     \
      /       \
     /         \
     \         /
      \       /
       \     /
        \   /
         \ /
          V

          ^
         / \
        /   \
       /     \
      /       \
      \       /
       \     /
        \   /
         \ /
          V

          ^
         / \
        /   \
       /     \
       \     /
        \   /
         \ /
          V

          ^
         / \
        /   \
        \   /
         \ /
          V

          ^
         / \
         \ /
          V

          ^
          V

Scoring
This is code-golf, so the program with the smallest number of bytes wins!
Standard loopholes are not allowed.

What is the output for "\x20\x20\x20\x20\x20\x20/\\\n/-\\\x20\x20/\x20\x20\\-\\\n|\x20\x20\\/\x20\x20\x20\x20\x20|\n\\---------/\n"

I don't really think the rules make sense. Rocks erode differently if they're rotated 45 degrees. But anyway.

Retina would work really well for this I think.

Rust
I gave up on this after a while, the instructions kind of seem ambiguous. However i did get some shrinky-looking rocks (see output). I also am pretty sure this needs to be done in a 2 dimensional space rather than in a 1 dimensional string as i tried here. My main "issue" is that I transform the given input by marking space as 'inside' or 'outside' the rock, unfortunately at this point it cannot distinguish between inside and the top/bottom edges.
enum State {
 OutsideLeft,CrossLI,Inside,CrossRI,OutsideRight,
}

const INPUT: &str = r#"
/----\
|     \------\
|            |
|            |
\------------/
"#;

fn precycle( mut data:Vec<char> ) -> Vec<char> {
    let mut state = State::OutsideLeft;
    let mut curcol = 0;
    let mut curline:Vec<char> = Vec::new();
    let mut lastline:Vec<char> = Vec::new();
    for mut i in 0..data.len() {
        if data[i]=='\n' {
            lastline = curline.to_vec();
            lastline.push(' ');
            curline.clear();
            curline.push(' ');
            curcol = 0;
        } else {
            curline.push(data[i]);
            curcol += 1;
        }
        let n = curcol%lastline.len();
        let n2 = lastline.len()-n;
        //println!("[{}]",lastline.iter().collect::<String>());
        //println!("[{}]",curline.iter().collect::<String>());
        //println!("({}{})({}{})>",data[i],state,lastline[n],curline[n]);
        //print!("{}{}>",data[i],state);
        match state {
        State::OutsideLeft  =>  {
            if      data[i]=='/' { state = State::CrossLI; }
            else if data[i]=='\\' { state = State::CrossLI; }
            else if data[i]=='|' { state = State::CrossLI; }
            else if data[i]=='<' { state = State::CrossLI; }
            if      data[i]==' ' { }
        } State::CrossLI => {
            if      data[i]=='/' { state = State::CrossRI; }
            else if data[i]=='\\' { state = State::CrossRI; }
            else if data[i]=='|' { state = State::CrossRI; }
            else if data[i]=='>' { state = State::CrossRI; }
            if data[i]==' ' { data[i]='-'; }
            if data[i]=='-' { state = State::Inside; }
        } State::Inside => {
            if      data[i]=='/' { state = State::CrossRI; }
            else if data[i]=='\\' { state = State::CrossRI; }
            else if data[i]=='|' { state = State::CrossRI; }
            else if data[i]=='>' { state = State::CrossRI; }
            if      data[i]==' ' { data[i] = '-'; }
        } State::CrossRI => {
            if  data[i]==' ' { state = State::OutsideRight; }
            if  data[i]=='\n' { state = State::OutsideLeft; }
        } State::OutsideRight => {
            if  data[i]==' ' { }
            if  data[i]=='\n' { state = State::OutsideLeft; }
        } }
        match state {
        State::CrossLI => {
            if curline[n]=='|' && lastline[n]=='.' { data[i]='9'; curline[n]='9'; }
        }
        State::CrossRI => {
            if curline[n]=='|' && lastline[n]=='.' { data[i]='8'; curline[n]='8'; }
            if curline[n]=='.' && lastline[n]=='8' { data[i-n-n2+1]='>'; }
            if curline[n]=='.' && lastline[n]=='|' { data[i-n-n2+1]='6'; }
        }
        State::OutsideLeft => {
            if curline[n]=='.' && lastline[n]=='|' { data[i-n-n2+1]='7'; curline[n] = '7'; }
            if curline[n]=='.' && lastline[n]=='9' { data[i-n-n2+1]='<'; }
        }
        _ => { }
        }
        //print!("{} ",state);

    }
    for mut i in 0..data.len() {
        if data[i]=='9' {data[i]='/'}
        if data[i]=='8' {data[i]='\\'}
        if data[i]=='7' {data[i]='\\'}
        if data[i]=='6' {data[i]='/'}
    }
    data
}

fn cycle( data:String ) -> String {
    data
    .replace(r#"^"#,r#"."#)
    .replace(r#"V"#,r#"."#)
    .replace(r#"/-\"#,r#".^."#)
    .replace(r#"\-/"#,r#".V."#)
    .replace(r#"-/\-"#,r#"----"#)
    .replace(r#"-\/-"#,r#"----"#)
    .replace(r#"/\-"#,r#"/--"#)
    .replace(r#"-/\"#,r#"--\"#)
    .replace(r#"\/-"#,r#"\--"#)
    .replace(r#"-\/"#,r#"--/"#)
    .replace(r#"./\."#,r#"...."#)
    .replace(r#".\/."#,r#"...."#)
    .replace(r#"/\"#,r#".."#)
    .replace(r#"\/"#,r#".."#)
    .replace(r#"-\"#,r#"\."#)
    .replace(r#"-/"#,r#"/."#)
    .replace(r#"/-"#,r#"./"#)
    .replace(r#"\-"#,r#".\"#)
    .replace(r#"->"#,r#">."#)
    .replace(r#"<-"#,r#".<"#)
    .replace(r#".-"#,r#"--"#)
    .replace(r#"-."#,r#"--"#)
}

fn main() {
    let mut inputv: Vec<char> = INPUT.chars().collect();
    let mut input0: Vec<char> = inputv;
    for j in 1..18 {
        let mut inputa = precycle( input0 );
        let pdata = inputa.iter().collect::<String>().replace("."," ");
        println!("{}",pdata);
        let mut input2 = cycle( inputa.iter().collect::<String>() );
        input0 = input2.chars().collect();
    }
}

output
/----\
|-----\------\
|------------|
|------------|
\------------/

 /--\
/----\------\
|------------\
\------------/
 \----------/

  /\
 /--\------\
<-----------\
 \----------/
  \--------/

  /\------\
 <---------\
  \--------/
   \------/

   /-----\
  <-------\
   \------/
    \----/

    /---\
   <-----\
    \----/
     \--/

     /-\
    <---\
     \--/
      \/

      ^
     <-\
      \/

     <\

     <\

     <\

     <\

     <\

     <\

     <\

     <\

     <\


text:
The symmetry of months
Introduction
Some months are completely symmetric, meaning they have central symmetry as well as reflection symmetry, like February of 2010:
     February 2010
┌──┬──┬──┬──┬──┬──┬──┐
│  │  │  │  │  │  │  │
├──┼──┼──┼──┼──┼──┼──┤
│  │  │  │  │  │  │  │
├──┼──┼──┼──┼──┼──┼──┤
│  │  │  │  │  │  │  │
├──┼──┼──┼──┼──┼──┼──┤
│  │  │  │  │  │  │  │
└──┴──┴──┴──┴──┴──┴──┘

Some months have only central symmetry, like February of 1996 or current month, the April of 2018:
      February 1996
          ┌──┬──┬──┬──┐
          │  │  │  │  │
 ┌──┬──┬──┼──┼──┼──┼──┤
 │  │  │  │  │  │  │  │
 ├──┼──┼──┼──┼──┼──┼──┤
 │  │  │  │  │  │  │  │
 ├──┼──┼──┼──┼──┼──┼──┤
 │  │  │  │  │  │  │  │
 ├──┼──┼──┼──┼──┴──┴──┘
 │  │  │  │  │
 └──┴──┴──┴──┘

       April 2018  ┌──┐
                   │  │
 ┌──┬──┬──┬──┬──┬──┼──┤
 │  │  │  │  │  │  │  │
 ├──┼──┼──┼──┼──┼──┼──┤
 │  │  │  │  │  │  │  │
 ├──┼──┼──┼──┼──┼──┼──┤
 │  │  │  │  │  │  │  │
 ├──┼──┼──┼──┼──┼──┼──┤
 │  │  │  │  │  │  │  │
 ├──┼──┴──┴──┴──┴──┴──┘
 │  │
 └──┘

And some are asymmetric, like the previous month, the March of 2018:
      March 2018
         ┌──┬──┬──┬──┐
         │  │  │  │  │
┌──┬──┬──┼──┼──┼──┼──┤
│  │  │  │  │  │  │  │
├──┼──┼──┼──┼──┼──┼──┤
│  │  │  │  │  │  │  │
├──┼──┼──┼──┼──┼──┼──┤
│  │  │  │  │  │  │  │
├──┼──┼──┼──┼──┼──┼──┘
│  │  │  │  │  │  │
└──┴──┴──┴──┴──┴──┘

Task
Take an input in form of a date, e.g.:

2018.04
2018.03
2010.02
1996.02

Output the corresponding symmetry, e.g.

2018.04 -> centrally symmetric
2018.03 -> asymmetric
2010.02 -> symmetric
1996.02 -> centrally symmetric

Rules

This is code golf, so the smallest number of bytes wins.
Standard loopholes are obviously not allowed.
Assume that the week starts with Monday (thanks to Angs and Arnauld for suggestion).
Consider only years between 1900 and 2100 (inclusive).
The input and output formatting rules are permissive, meaning you can use any equivalent format that is native to the language of your choice.
Base your solution on the Gregorian calendar.

Consider that dates are weird, you may want to specify exactly the rules, or limit the possible input to a small range (say, 1901-2099)

Things to avoid when writing challenges/Adding unnecessarily stuff includes "Making answers calculate f(x) for every x in a list." What about "take an input in form of a date"?

Welcome to PPCG, and nice first challenge! Although this challenge is good, in the future if you want some feedback on the challenge before posting, you can post it in the sandbox.

@user202729 Fair points, I'll clarify that and change the input form, thanks!

Should the output be strictly the mentioned strings, or any 3 distinct values?

Could you add (links to) images for those on mobile, which stupidly doesn't use a monospaced font for code?

@Uriel I've added details about the input/output format

I believe it's your choice to make, however I'd just make a note that strict output is usually frowned upon on the site

@Uriel I guess you're right, the length of program depends strongly on that, so I think I'll allow for permissive output as well.

Does between 1900 and 2100 include 1900 and 2100 ? (important for leap year reasons. I'd obviously prefer "no")

What timezone and country should the months be calculated for? Months are a weird concept

@Ferrybig Gregorian calendar. AFAIK that's not affected by timezone/country.

(wait a minute, Gregorian calendar or Julian calendar? I suggested [1901-2099] but you decide to use [1900-2100] so they're different for some inputs)

@mkierc May we use Sunday as first day of the week?

JavaScript (ES6), 55 bytes
Saved 6 bytes thanks to @Neil
Takes input in currying syntax (year)(month). Returns false for asymmetric, true for centrally symmetric and 0 for completely symmetric.
y=>m=>(n=(g=_=>new Date(y,m--,7).getDay())()+g())&&n==7

Try it online!
How?
We define the function g() which returns the weekday of yyyy/mm/01, as an integer between 0 = Monday and 6 = Sunday.
g = _ => new Date(y, m--, 7).getDay()

Because getDay() natively returns 0 = Sunday to 6 = Saturday, we shift the result to the expected range by querying for the 7th day instead.
Then we define:
n = g() + g()

Because the constructor of Date expects a 0-indexed month and because g() decrements m after passing it to Date, we actually first compute the weekday of the first day of the next month and then add that of the current one.
Completely symmetric months
Completely symmetric months start with a Monday and are followed by a month which also starts with a Monday. This is only possible for February of a non-leap year.
- Feb --------------    - Mar --------------
Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su
--------------------    --------------------
01 02 03 04 05 06 07    01 02 03 04 05 06 07
08 09 10 11 12 13 14    08 09 10 11 12 13 14
15 16 17 18 19 20 21    15 16 17 18 19 20 21
22 23 24 25 26 27 28    22 23 24 25 26 27 28
                        29 30 31

This leads to n = 0.
Centrally symmetric months
Centrally symmetric months are months for which the sum of the weekday of their first day and that of the next month is 7.
- M ----------------    - M+1 --------------
Mo Tu We Th Fr Sa Su    Mo Tu We Th Fr Sa Su
--------------------    --------------------
 0  1 [2] 3  4  5  6     0  1  2  3  4 [5] 6
--------------------    --------------------
      01 02 03 04 05                   01 02
06 07 08 09 10 11 12    03 04 05 06 07 07 09
13 14 15 16 17 18 19    ...
20 21 22 23 24 25 26
27 28 29 30 31

Hence the second test: n == 7.

No built-in, 93 bytes
Uses Zeller's congruence. Same I/O format as the other version.
y=>m=>(n=(g=_=>(Y=y,((m+(m++>2||Y--&&13))*2.6|0)+Y+(Y>>2)-6*~(Y/=100)+(Y>>2))%7)()+g())&&n==7

Try it online!

I thought it was true, false and filenotfound instead of 0…

g=m=>new Date(y,m,7).getDay() saves 6 bytes.

T-SQL, 213 bytes (strict I/O rules)
SET DATEFIRST 1SELECT CASE WHEN a+b<>8THEN'a'WHEN a=1THEN''ELSE'centrally 'END+'symetric'FROM(SELECT DATEPART(DW,f)a,DATEPART(DW,DATEADD(M,1,f)-1)b FROM (SELECT CONVERT(DATETIME,REPLACE(s,'.','')+'01')f FROM t)y)x

The above query considers the strict input/output formatting rules.
The input is taken from the column s of a table named t:
CREATE TABLE t (s CHAR(7))
INSERT INTO t VALUES ('2018.04'),('2018.03'),('2010.02'),('1996.02')

Ungolfed:
SET DATEFIRST 1
SELECT *, CASE WHEN a+b<>8 THEN 'a' WHEN a=1 AND b=7 THEN '' ELSE 'centrally ' END+'symetric'
FROM (
    SELECT *,DATEPART(WEEKDAY,f) a,
        DATEPART(WEEKDAY,DATEADD(MONTH,1,f)-1) b
    FROM (SELECT *,CONVERT(DATETIME,REPLACE(s,'.','')+'01')f FROM t)y
) x

SQLFiddle 1
T-SQL, 128 bytes (permissive I/O rules)
SET DATEFIRST 1SELECT CASE WHEN a+b<>8THEN 1WHEN a=1THEN\END FROM(SELECT DATEPART(DW,d)a,DATEPART(DW,DATEADD(M,1,d)-1)b FROM t)x

If the format of the input and of the output can be changed, I would choose to input the first day of the month, in a datetime column named d:
CREATE TABLE t (d DATETIME)
INSERT INTO t VALUES ('20180401'),('20180301'),('20100201'),('19960201')

The output would be 1 for asymetric, 0 for symetric, NULL for centrally symetric.
If we can run it on a server (or with a login) configured for BRITISH language, we can remove SET DATEFIRST 1 saving 15 more bytes.
SQLFiddle 2

Nice work. Not sure if it'll work in all versions, but on SQL 2012 I was able to save 15 bytes by using CONVERT(DATETIME,s+'.01') instead of REPLACE. You can also drop the space in FROM (SELECT

It works, but it's dependant on the DATEFORMAT setting. For example, if we use SET LANGUAGE BRITISH, then CONVERT(DATETIME,'2018.02.01') would be January 2nd, instead of February 1st.

Haskell, 170 bytes
import Data.Time.Calendar
import Data.Time.Calendar.WeekDate
a%b=((\(_,_,a)->a).toWeekDate.fromGregorian a b$1)!gregorianMonthLength a b
1!28=2
4!29=1
7!30=1
3!31=1
_!_=0

Returns 2 for centrally symmetric, 1 for symmetric and 0 for asymmetric

@TuukkaX Sorry for confusion - this is my first challenge, I've changed the rules so they also allow permissive output formats so it can be more "in spirit" of the code-golf.

Python 2, 118 104 bytes
Thanks to Jonathan Allan and Dead Possum for the improvements!
from calendar import*
def f(*d):_=monthcalendar(*d);print all(sum(_,[]))+(_[0].count(0)==_[-1].count(0))

Python 3, 122 105 bytes
from calendar import*
def f(*d):_=monthcalendar(*d);print(all(sum(_,[]))+(_[0].count(0)==_[-1].count(0)))

Input

First is the year
Second is the month

Output

0 = no symmetry
1 = central symmetry
2 = complete symmetry

Welcome to the site! You may not assume that input is stored in a variable (such as Y or M), so this is currently a snippet and invalid. If you change the variables to calls to input() however, this will be perfectly fine.

@cairdcoinheringaahing Thanks for the welcome! Fixed user input :)

Welcome! Tweaks for -9 bytes here - all import, unpacked input, _[0]+_[-1]->sum(..)

Some tricks to get it down 13 bytes here

...and another byte using Dead Possum's sum trick - here

Red, 199, 168 161 bytes
func[d][t: split d"."y: do t/1 m: do t/2 a: to-date[1 m y]b: a + 31
b/day: 1 b: b - 1 if(1 = s: a/weekday)and(7 = e: b/weekday)[return 1]if 8 - e = s[return 2]0]

Try it online!
0 - asymmetric
1 - symmetric
2 - centrally symmetric
More readable:
f: func[d][                  ; Takes the input as a string
    t: split d "."           ; splits the string at '.'
    y: do t/1                ; stores the year in y
    m: do t/2                ; stores the month in m
    a: to-date[1 m y]        ; set date a to the first day of the month
    b: a + 31                ; set date b in the next month
    b/day: 1                 ; and set the day to 1st
    b: b - 1                 ; find the end day of the month starting on a
    s: a/weekday             ; find the day of the week of a
    e: b/weekday             ; find the day of the week of b
    if(s = 1) and (e = 7)    ; if the month starts at Monday and ends on Sunday
        [return 1]           ; return 1 fo symmetric
    if 8 - e = s             ; if the month starts and ends on the same day of the week
        [return 2]           ; return 2 for centrally symmetric
    0                        ; else return 0 for assymetric
]

Mathematica, 137 bytes
a=#~DateValue~"DayName"&;b=a/@{2}~DateRange~{3};Which[{##}=={0,6},1,+##>5,0,1>0,-1]&@@(Position[b,a@#][[1,1]]~Mod~7&)/@{{##},{#,#2+1,0}}&

Pure function. Takes the year and the month as input and returns -1 for asymmetric months, 0 for centrally symmetric months, and 1 for fully symmetric months. Not sure why this language can't convert from a weekday to a number by default...

Bash + GNU utilities, 70
date -f- +%u<<<"$1/1+1month-1day
$1/1"|dc -e??sad8*la-55-rla+8-d*64*+p

Input is formatted as YYYY/MM.
Output is numeric, as follows:

less than 0: centrally symmetric
exactly 0: symmetric
greater than 0: asymmetric

I assume this output format is acceptable for this question.
Try it online!

C, 111 bytes
a;g(y,m){y-=a=m<3;return(y/100*21/4+y%100*5/4+(13*m+16*a+8)/5)%7;}f(y,m){a=g(y,m)+g(y,m+1);return(a>0)+(a==7);}

Invoke f(year, month), 0 for completely symmetric, 1 for asymmetric, 2 for centrally symmetric.

IIRC you can abuse UB on GCC by replacing return with y= (the first parameter) and falling out of the function.

Perl 6, 74 bytes
{{{$_==30??2!!$_%7==2}(2*.day-of-week+.days-in-month)}(Date.new("$_-01"))}

Bare block, implicitly a function of 1 argument, a string like "2012-02". Returns:
2     # Fully symmetric
True  # Centrally symmetric
False # Asymmetric

When the pattern is symmetric, as .day-of-week increases by 1, .days-in-month would need to move by 2 in order to still match (the month would be starting a day later but need to end a day earlier), so 2 * .day-of-week + .days-in-month gives us a measure of that gap. Modulo 7 it should be 1 to get symmetry, but we can first cheaply check for the non-leap February by checking that total before modulo (Monday and 28 days per month is the minimum possible combination).
I'm surprised that this takes so many bytes, but fully 36 bytes are needed for just making a date and getting the day of the week and days in that month.


text:
Asterisk spiral
Given the spiral of size S and the step N, output the "square" S*S spiral having N asterisks, built from the outer to inner radius clockwise.
Test cases (examples) below.

Input: 4 3
Output:
***

Input: 4 6
Output:
****
   *
   *

Input: 4 11
Output:
****
   *
*  *
****

Input: 6 18
Output:
******
     *
     *
*    *
*    *
******

Input: 6 22
Output:
******
***  *
*    *
*    *
*    *
******

Input: 6 27
Output:
******
******
*   **
*   **
*   **
******

Input: 1 1
Output:
*

It's not necessary to handle the cases when:

provided N asterisks can't "fit" in the spiral of given S*S dimensions.
either N or S is zero.

The challenge is code-golf, shortest bytes answer wins, any languages can be used.
Your output may have as many trailing (but not leading) spaces/newlines as you wish.

Can we have trailing spaces/newlines?

I'd call S size (or at least diameter) rather than radius

@Luis fair point!

@LuisMendo Or side length.

Dear friends, please vote on answers also, not just question. It's easy to make this challenge. Providing an answer to it is (I think) definitely more difficult.

Only you think so. Writing a well-received and clear challenge is very difficult. (just look at the comment thread right here, there are some suggestions after the challenge had been posted)

related: https://codegolf.stackexchange.com/questions/89725/alphabet-spiral

@Luis, lol, i havent noticed that instead of replacing the word radius with size, I replaced spiral with size xD funny that nobody else noticed

@nicael TBH I did, but I didn't want to be boring :-)

MATL, 17 16 bytes
UGlYLGoQ&P->42*c

Try it online!
Explanation (with example)
Consider inputs 4 and 11 as an example.
U       % Implicit input: S. Push S^2
        % STACK: 16
G       % Push S again
        % STACK: 16, 4
lYL     % Outward, clockwise, east-first spiral of that size
        % STACK: 16,
                 [ 7  8  9 10;
                   6  1  2 11;
                   5  4  3 12;
                  16 15 14 13]
GoQ     % Push S, compute parity, add 1. Gives 1 for even S, 2 for odd
        % STACK: 16,
                 [ 7  8  9 10;
                   6  1  2 11;
                   5  4  3 12;
                  16 15 14 13],
                 1
&P      % Flip along that dimension (1 is vertical, 2 is horizontal).
        % This corrects for the orientation of the spiral
        % STACK: 16,
                 [16 15 14 13;
                   5  4  3 12;
                   6  1  2 11;
                   7  8  9 10]
-       % Subtract, element-wise. The upper-left corner becomes 0
        % STACK: [ 0  1  2  3
                  11 12 13  4
                  10 15 14  5
                   9  8  7  6]
>       % Implicit input (below): N. Greater than?, element-wise.
        % This transforms the first N entries, starting from
        % upper-left, inward, east-first, into 1, and the rest
        % into 0
        % STACK: [1 1 1 1;
                  0 0 0 1;
                  1 0 0 1;
                  1 1 1 1]
42*     % Multiply each entry by 42
        % STACK: [42 42 42 42;
                   0  0  0 42;
                  42  0  0 42;
                  42 42 42 42]
c       % Convert to char. Char 0 will be displayed as space.
        % Implicit display
        % STACK: ['****';
                  '   *';
                  '*  *';
                  '****']

Wow, I was never good at golfing, but solve it with 17 bytes... That looks like magic :) (I know that possibly the shorter answers are coming, but you're first and here're my impressions :)

Part of the job is done by a built-in spiral function. I just added an explanation

@nicael Welcome to the world of golfing languages aimed for specific purposes. :)

+1 for full example alongside the explanation

Why built-in...

@user202729 https://codegolf.stackexchange.com/questions/125966/wind-me-a-number-snake/125969#comment309973_125969

Stax, 19 bytes
±♪☺ÿzMæ¡♠à╣♂7☼V♀§9↓

Run and debug it
It starts by building a string that has all the characters in the result with all the asterisks left-aligned.  Then it it takes increasingly large slices off the end of the string, and "wraps" them around a grid as it rotates the grid.
Here's the same program, unpacked, ungolfed, and commented.
'**     repeat "*" specified number of times
,J(     square the top of the input stack, and right-pad string to that length
z       push an empty array - this is the result grid built up in the loop
{       begin a block to loop
  ~     push grid to the input stack
  ihNv  push -(i / 2) - 1 where i is the 0-based iteration index using integer division
  :/]   split the string at that index and wrap the second half in a singleton array
  ,     pop the grid from the input stack
  rM+   rotate the grid clockwise, then prepend the split string as the new first row
  n     copy what's left of the original string to top of stack for the loop condition
w       while; execute block until condition is truthy
m       display resulting grid

Run and debug it

It inordinatly amuses me that on android this answer contains an orange blob smiley.

@StarWeaver There are many answers in Stax that do so.

I was really confused when I read the explanation and didn't see one. I just thought that Stax had a really weird code page!

@ndm13: I suppose it does have a weird code page.  It's derived from CP437 which is a "real" encoding that has the same character in it.  You should see the same smiling face if you follow that link on your phone.

APL (Dyalog), 65 bytes
' *'[1+⎕>⊖∘⌽⍣o(⊖×⍨-,⍨⍴∘(⍋+\)×⍨↑(⌈2÷⍨×⍨),(+⍨⍴1,⊢,¯1,-)(/⍨)2/⍳)o←⎕]

Try it online!
The code for the spiral matrix is taken from another answer of mine.

Your code draws the spiral in the wrong direction if the N is odd :)

@nicael fixed (more like patched). thanks

But... https://i.stack.imgur.com/gGJsS.png

Maybe I'm using the input in the wrong way?

@nicael arghh. OK, I think its fine now.

It is fine, indeed!

Python 2, 117 bytes
n,k=input()
i=0;d=1
l=(' '*n+'\n')*n
exec"l=l[:i]+'*'+l[i+1:];d=[~n/d*cmp(d*d,2),d][' '<l[i+d:]<'*'];i+=d;"*k
print l

Try it online!

Python 2, 150 bytes
S,N=input()
X=y=n=0
Y=x=c=-1
s=eval(`[[' ']*S]*S`)
exec"if n%S<1:S-=c%2<1;X,Y=-Y,X;c+=1;n=0\nx+=X;y+=Y;s[y][x]='*';n+=1\n"*N
for i in s:print`i`[2::5]

Try it online!

Charcoal, 34 bytes
ＮθＦＥ⮌Ｅ⊗Ｎ∨ι¹÷⁺ι¬¬κ²«Ｆ‹θι≔θι×ι*≧⁻ιθ↷

Try it online! Link is to verbose version of code. Explanation:
Ｎθ

Input N.
ＦＥ⮌Ｅ⊗Ｎ∨ι¹÷⁺ι¬¬κ²«

The lengths of the spiral arms (excluding corners) are S-1, S-1, S-1, S-2, S-2, S-3, ..., 3, 2, 2, 1, 1, 1. This is formed by starting with the range from 0 up to but excluding 2S, changing the 0 to 1, reversing it, adding 1 to each element after the first, and finally integer dividing all the elements by 2. This list is then looped over.
Ｆ‹θι≔θι

If there are fewer stars left to draw than the length of the next arm, reduce the arm to that length.
×ι*

Draw the appropriate number of stars.
≧⁻ιθ

Subtract from the number of stars remaining.
↷

Rotate the drawing direction by 90° clockwise.

PHP, 118 bytes
adjusted and golfed my solution for the Alphabet Spiral.
for($w=$n=$argv[$s=1],$r="*";--$argv[2];$r[$p+=$s*$d+$s]="*")if(!$c=++$c%$n)($d^=$w)?$n--:$s=-$s;echo wordwrap($r,$w);

Run with php -nr '<code>' <S> <N> or try it online.

J, 60 56 Bytes
-4 Bytes by modifying the build proccess for the spiral so that subtracting it from y^2 was unnecessary
4 :'''* ''{~x<|."1|.(|:@|.,<:@{:@{:-i.@#)^:(+:<:y),.*:y'

Try it online!
Explanation coming soon now.
Explanation:
4 :'''* ''{~x<|."1|.(|:@|.,<:@{:@{:-i.@#)^:(+:<:y),.*:y'  | Explicit dyad definition
                    (|:@|.,<:@{:@{:-i.@#)^:(+:<:y),.*:y   | Generate a y by y inward spiral
                                                  ,.*:y   | The matrix [[y^2]]
                    (                   )^:(+:<:y)        | 2*(y-1) times...
                     |:@|.                                | Rotate
                          ,                               | Append
                                    i.@#                  | [0..len(n)-1]
                           <:@{:@{:-                      | Subtracted from the previous value and decremented
              |."1|.                                      | Flip around antidiagonal
            x>                                            | Test if each entry is less than x
    '' *''{~                                              | ' ' for 0, '*' for 1

Examples:
   3 :'(|:@|.,<:@{:@{:-i.@#)^:(+:<:y),.*:y' 4
7  8  9 10
6 15 16 11
5 14 13 12
4  3  2  1
   3 :'|."1|.(|:@|.,<:@{:@{:-i.@#)^:(+:<:y),.*:y' 4
1  2  3 4
12 13 14 5
11 16 15 6
10  9  8 7
   11(4 :'x<|."1|.(|:@|.,<:@{:@{:-i.@#)^:(+:<:y),.*:y') 4
0 0 0 0
1 1 1 0
0 1 1 0
0 0 0 0
   11(4 :'''* ''{~x<|."1|.(|:@|.,<:@{:@{:-i.@#)^:(+:<:y),.*:y') 4
****
   *
*  *
****

May you also add a link to the executable example?

@nicael Added :)

Java 10, 284 282 281 263 bytes
s->n->{var c=new char[s][s];for(var d:c)java.util.Arrays.fill(d,' ');for(int i=0,j=0,y=0,x=1,u=s-1,l=0;n-->0;c[j][i]=42,i+=x,j+=y,l+=i==l&x==0?1:0,u-=i==l&j==l&y<1?1:0)if(x!=0){var b=x>0?i<u:i>l;y=b?0:x;x=b?x:0;}else{var b=y>0?j<u:j>l;x=b?0:-y;y=b?y:0;}return c;}

A fun challenge!
Try it online here.
Thanks to Kevin Cruijssen for golfing 18 bytes.
Ungolfed version:
s -> n -> { // lambda taking two integer arguments in currying syntax
    var c = new char[s][s]; // the matrix containing the spiral
    for(var d : c) // for every row
        java.util.Arrays.fill(d, ' '); // fill it with spaces
    for(int i = 0, j = 0, // the coordinates of the next '*'
            y = 0, x = 1, // the direction to move in
            u = s-1, l = 0; // the upper and lower bounds
        n-- > 0; // decrecement the length of the spiral and repeat as many times
        c[j][i] = 42, // draw the '*', 42 is ASCII code
        i += x, j += y, // move to the next cell
        l += i == l & x == 0 ? 1 : 0, // adjust lower bound if necessary
        u -= i == l & j == l & y < 1 ? 1 : 0) // adjust upper bound if necessary
        if(x != 0) { // if moving in x direction
            var b = x > 0 ? i < u : i > l; // if we hit the bounds
            y = b ? 0 : x; // flip directions,
            x = b ? x : 0; // turning around
        } else { // if moving in y direction
            var b = y > 0 ? j < u : j > l; // if we hit the bounds
            x = b ? 0 : -y; // flip directions,
            y = b ? y : 0;  // turning around
        }
    return c; // return the matrix
}

263 bytes Last two loops are mainly changed, and a var b is added so you only have to do the x>0?i<u:i>l and y>0?j<u:j>l once each, instead of twice each.

@KevinCruijssen great golf, thanks!

Suggest if(x>0?i<u:i>l)y=0;else{y=x;x=0;}else if(y>0?j<u:j>l)x=0;else{x=-y;y=0;} instead of {var b=x>0?i<u:i>l;y=b?0:x;x=b?x:0;}else{var b=y>0?j<u:j>l;x=b?0:-y;y=b?y:0;}

Kotlin, 361 355 353 334 bytes
6 bytes saved thanks to Jonathan
2 bytes saved changing to when
19 bytes saved switching to lambda & tracking outer edges
{s:Int,n:Int->var a=Array(s,{_->Array(s,{_->' '})})
var r=0
var c=0
var d=0
var e=0
var f=1
var g=s-1
var h=g
for(i in 1..n){a[r][c]='*'
when(d){0->if(c<g)c++
else{d=1
r++
g--}
1->if(r<h)r++
else{d=2
c--
h--}
2->if(c>e)c--
else{d=3
r--
e++}
3->if(r>f)r--
else{d=0
c++
f++}}}
for(i in 0..s-1){for(j in 0..s-1)print(a[i][j])
println()}}

Try it online!

I'm not really sure how to try it since the input field is empty.

@nicael It's a function. this may be easier to use - the call is made in the footer.

I don't know Kotlin much at all but believe ==' ' may be replaced by <'*'. Also d==0 with d<1 and d==3 with d>2. These seem like pretty fundamental golfs so there are probably others too!

@nicael you can put two integers in input field, size on first line, number on second.

@jonathan thank you. Just starting out with Kotlin and golf so haven't figured out simple things like that as yet.

@JohnWells indeed, it works. Somehow it's too slow, but it doesn't matter.

JavaScript (Node.js), 167 164 163 bytes

thanks to @Erik the Outgolfer  and @nicael for spaces (3 bytes)
thanks to @micha for join``split, instead of map (1 byte)

(l,s)=>{a=(b=[...Array(l)]).map(x=>b.map(_=>" "))
for(d=1,x=y=D=0;s--;x+=d,y+=D)a[y][x]="*",(a[y+D]||[])[x+d]!=" "?[d,D]=[-D,d]:0
return a.join`
`.split`,`.join``}

Try it online!

Nice, it works! Can you remove spaces/newlines to make it even shorter?

@nicael Looks like yes.

Beautiful! If Kotlin and Java version would use the same method they would be a lot shorter! Such an elegant way of detecting when you hit the spiral or border and then turn the "turtle". Very clever! One byte less: change the return into return a.join\
`.split`,`.join```.

@micha first of all thank you :). second a.join .split,.join`` doesnt output the spiral "nicely"(with new lines) so i think its a problem

@DanielIndie, the newline got formatted away, first join should have a newline. See it